Bug 1255107

Summary: Sort command sorts on the whole line when it should sort on first column.
Product: Red Hat Enterprise Linux 7 Reporter: Ashkan <akn.shp+redhat>
Component: coreutilsAssignee: Ondrej Vasik <ovasik>
Status: CLOSED DUPLICATE QA Contact: qe-baseos-daemons
Severity: high Docs Contact:
Priority: unspecified    
Version: 7.0CC: pbrady
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-08-19 20:30:13 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Ashkan 2015-08-19 16:12:41 UTC
Description of problem:
While sorting files, sometimes sort command sorts the whole line even if it is used like sort -k1,1 and there are spaces in the file.

Version-Release number of selected component (if applicable):


How reproducible:
Always reproducible

Steps to Reproduce:
Create a file with this content:
a
b
B
A

Another file with this content:
a 1
b 0
B 1
A 0

Use sort -k1,1 filename to sort the files the first one results in

Actual results:
sorting result of first file:
a
A
b
B

sorting result of second file:
A 0
a 1
b 0
B 1


Expected results:
Note that in the first result a is before A and in the second a is after A. It shouldn't be different. Either the first result should be:
A
a
b
B

Or the second result should be:
a 1
A 0
b 0
B 1

It just needed to be consistent across both files.

Additional info:
Centos-7.0-1406-x86_64
sort version: 8.22
LC_COLLATE is not set.
LC_ALL is not set.
LANG is set to en_US.UTF-8
LC_CTYPE is not set.

Comment 2 Ondrej Vasik 2015-08-19 20:30:13 UTC
I believe this is a duplicate of https://bugzilla.redhat.com/show_bug.cgi?id=1148347 .
Actually, when using LC_ALL=C sort , you will get consistent sort results even with current coreutils (however, different from your expectations).

*** This bug has been marked as a duplicate of bug 1148347 ***