Mailinglist Archive: opensuse-bugs (5047 mails)

< Previous Next >
[Bug 751690] /usr/bin/sort produces incorrect results.

https://bugzilla.novell.com/show_bug.cgi?id=751690

https://bugzilla.novell.com/show_bug.cgi?id=751690#c2


--- Comment #2 from Philipp Thomas <pth@xxxxxxxx> 2012-03-13 14:13:13 CET ---
Additional notes from upstream:

note it's the en_US locale rather than anything
UTF8 specific that is causing this:

$ { echo 16301 3.574885; echo 163 0.171036; } | LANG=en_US sort --debug
sort: using `en_US' sorting rules
16301 3.574885
______________
163 0.171036
____________

We were wondering about updating the --debug option to make this apparent,
though that was thought too invasive for the benefit provided.

The following confirms that the ' ' and '.' are discounted from the sort:

$ { echo 16301 3.574885; echo 163 0.121036; } | LANG=en_US sort --debug
sort: using `en_US' sorting rules
163 0.121036
____________
16301 3.574885
______________


Also note above that the whole line is compared.
If you want to compare only field 1 first:

$ { echo 16301 3.574885; echo 163 0.171036; } | LANG=en_US sort -k1,1 --debug
sort: using `en_US' sorting rules
163 0.171036
___
____________
16301 3.574885
_____

Or only field 1 in isolation:

$ { echo 16301 3.574885; echo 163 0.171036; } | LANG=en_US sort -k1,1 -s
--debug
sort: using `en_US' sorting rules
sort: leading blanks are significant in key 1; consider also specifying `b'
163 0.171036
___
16301 3.574885
_____

Or you can implicitly restrict to field 1 with a numeric sort like:

$ { echo 16301 3.574885; echo 163 0.171036; } | LANG=en_US sort -n --debug
sort: using `en_US' sorting rules
163 0.171036
___
16301 3.574885
_____
______________

--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

< Previous Next >
References