--- Begin Message ---
Subject: |
case sensitivity buggy in sort |
Date: |
Thu, 1 Sep 2011 10:58:58 +0200 |
sort (GNU coreutils) 8.12
The case-sensitivity looks buggy in sort. Have a look at these examples:
$ cat bbb
A B b 0
a B b 0
A b b 1
$ sort bbb
a B b 0
A B b 0
A b b 1
$ sort -k1,2 bbb
a B b 0
A b b 1
A B b 0
$ cat ccc
A 2 b 0
a 2 b 0
A 1 b 1
$ sort ccc
A 1 b 1
a 2 b 0
A 2 b 0
$ sort -k1 ccc
A 1 b 1
a 2 b 0
A 2 b 0
$ sort -k1,2 ccc
A 1 b 1
a 2 b 0
A 2 b 0
$ sort -k1,1 ccc
a 2 b 0
A 1 b 1
A 2 b 0
$ cat ddd
A2 b 0
a2 b 0
A1 b 1
$ sort ddd
A1 b 1
a2 b 0
A2 b 0
$ sort -k1 ddd
A1 b 1
a2 b 0
A2 b 0
$ sort -k1,1 ddd
A1 b 1
a2 b 0
A2 b 0
$ sort -k1,2 ddd
A1 b 1
a2 b 0
A2 b 0
$ sort -k1,3 ddd
A1 b 1
a2 b 0
A2 b 0
--- End Message ---
--- Begin Message ---
Subject: |
Re: bug#9418: case sensitivity buggy in sort |
Date: |
Thu, 01 Sep 2011 10:32:45 -0600 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.20) Gecko/20110817 Fedora/3.1.12-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.12 |
tag 9418 notabug
thanks
On 09/01/2011 02:58 AM, MichaĆ Janke wrote:
sort (GNU coreutils) 8.12
The case-sensitivity looks buggy in sort. Have a look at these examples:
Thanks for the report. However, this is most likely due to your choice
of locale, and not a bug in sort; this is a FAQ:
https://www.gnu.org/software/coreutils/faq/#Sort-does-not-sort-in-normal-order_0021
Using 'sort --debug' will help expose the issue.
$ sort -k1,2 bbb
a B b 0
A b b 1
A B b 0
$ sort --debug bbb -k1,2
sort: using `en_US.UTF-8' sorting rules
sort: leading blanks are significant in key 1; consider also specifying `b'
a B b 0
___
_______
A b b 1
___
_______
A B b 0
___
_______
$ LC_ALL=C ../coreutils/src/sort --debug bbb -k1,2
../coreutils/src/sort: using simple byte comparison
A B b 0
___
_______
A b b 1
___
_______
a B b 0
___
_______
See the difference? In the C locale, you get ascii sorting (A comes
before B comes before a comes before b), in the en_US.UTF-8 locale, you
get dictionary collation sorting (a comes before A comes before b comes
before B).
--
Eric Blake address@hidden +1-801-349-2682
Libvirt virtualization library http://libvirt.org
--- End Message ---