sort wierdness

Neil Bird neil at fnxweb.com
Fri Nov 5 12:47:18 UTC 2010


   I am seeing sort treat '@' specially; in particular, it wanders around 
the sort order depending upon the rest of the input line.  Anyone have an 
explanation?  I guess it's something to do with locale, but the input 
strings affecting it as well make no sense to me.

$ locale
LANG=en_GB.UTF-8
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_MONETARY="en_GB.UTF-8"
LC_MESSAGES="en_GB.UTF-8"
LC_PAPER="en_GB.UTF-8"
LC_NAME="en_GB.UTF-8"
LC_ADDRESS="en_GB.UTF-8"
LC_TELEPHONE="en_GB.UTF-8"
LC_MEASUREMENT="en_GB.UTF-8"
LC_IDENTIFICATION="en_GB.UTF-8"
LC_ALL=


sort input:
Abbot',              'COMP
CobraP',             'COMP
CobraU',             'COMP
@',                  'COMP
CTM',                'COMP
Jobby',              'COMP

gives:
Abbot',              'COMP
CobraP',             'COMP
CobraU',             'COMP
@',                  'COMP
CTM',                'COMP
Jobby',              'COMP


sort input:
Abbot',              'C
CobraP',             'C
CobraU',             'C
@',                  'C
CTM',                'C
Jobby',              'C

gives:
Abbot',              'C
@',                  'C
CobraP',             'C
CobraU',             'C
CTM',                'C
Jobby',              'C


sort input:
Abbot',
@',
CobraP',
CobraU',
CTM',
Jobby',

gives:
@',
Abbot',
CobraP',
CobraU',
CTM',
Jobby',


   'LC_ALL=C sort' gives that last order, nomatter the input, as I'd expect.

-- 
[neil at fnx ~]# rm -f .signature
[neil at fnx ~]# ls -l .signature
ls: .signature: No such file or directory
[neil at fnx ~]# exit


More information about the users mailing list