GNU bug report logs - #22109
Sort gives incorrect order when changing delimiters

Previous Next

Package: coreutils;

Reported by: Ed Brambley <edbrambley <at> gmail.com>

Date: Mon, 7 Dec 2015 16:17:03 UTC

Severity: normal

Tags: notabug

Done: Eric Blake <eblake <at> redhat.com>

Bug is archived. No further changes may be made.

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ed Brambley <edbrambley <at> gmail.com>
To: bug-coreutils <at> gnu.org
Subject: Sort gives incorrect order when changing delimiters
Date: Mon, 7 Dec 2015 15:36:12 +0000
[Message part 1 (text/plain, inline)]
The following problem came to light following a StackOverflow question [1].
The lexical ordering of sort appears to depend on the delimiter used, and I
believe it shouldn't. As a minimal example:

### Correct ordering ###
$ printf "1,a,1\n2,aa,2" | LC_ALL=C sort -k2 -t,
1,a,1
2,aa,2

### Incorrect ordering by replacing the "," delimiter by "~" ###
$ printf "1~a~1\n2~aa~2" | LC_ALL=C sort -k2 -t~
2~aa~2
1~a~1

I think this is because, in ASCII, "," < "a" < "~".

Many thanks,
Ed

[1]
http://stackoverflow.com/questions/34134677/trying-to-understand-the-sort-utilty-in-linux
[Message part 2 (text/html, inline)]

This bug report was last modified 9 years and 167 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.