GNU bug report logs - #9580
sort 8.5 bug?

Previous Next

Package: coreutils;

Reported by: Sean Sun <sean.x.sun <at> gmail.com>

Date: Thu, 22 Sep 2011 21:46:01 UTC

Severity: normal

Tags: notabug

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

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Sean Sun <sean.x.sun <at> gmail.com>
Subject: bug#9580: closed (Re: bug#9580: sort 8.5 bug?)
Date: Thu, 22 Sep 2011 22:03:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#9580: sort 8.5 bug?

which was filed against the coreutils package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 9580 <at> debbugs.gnu.org.

-- 
9580: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9580
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Eric Blake <eblake <at> redhat.com>
To: Sean Sun <sean.x.sun <at> gmail.com>
Cc: 9580-done <at> debbugs.gnu.org
Subject: Re: bug#9580: sort 8.5 bug?
Date: Thu, 22 Sep 2011 16:01:44 -0600
tag 9580 notabug
thanks

On 09/22/2011 02:55 PM, Sean Sun wrote:
> So basi­cally, append­ing a let­ter after ‘.’ would reverse the sort order.
> That doesn't look quite right. Is there an explanation for this behavior?
> I've tried the same on a Mac, and their sort (5.93) woks just fine.

Thanks for the report, but this is not a bug in sort.  Actually, both 
versions that you tried (8.5 and 5.93) sort in the same way, where the 
difference is in your choice of locale, and you are hitting this FAQ:
https://www.gnu.org/software/coreutils/faq/#Sort-does-not-sort-in-normal-order_0021

Newer coreutils added a --debug option to help you learn why the bug is 
in your expectations and not in sort (8.13 is current, but --debug has 
been present since 8.6).  So let's use it:

$ printf '.\nBAD.\n.s\nBAD.s\n' | sort --debug
sort: using `en_US.UTF-8' sorting rules
.
_
BAD.
____
BAD.s
_____
.s
__

$ printf '.\nBAD.\n.s\nBAD.s\n' | LC_ALL=C sort --debug
sort: using simple byte comparison
.
_
.s
__
BAD.
____
BAD.s
_____


Remember, the en_US.UTF-8 locale uses dictionary order collation, which 
treats punctuation as insignificant, and blends case.  That is, 's' and 
'.s' collate as the same string, and '.s' is larger than 'BAD.' since 
's' comes later in the alphabet than 'B'.

On the other hand, the C locale uses ASCII ordering, where every byte is 
significant, and '.' sorts before 'B'.

>
> I've also tried set LC_ALL='C'. Just in case it's a funky locale problem,
> but didn't make a difference.

Are you sure you used the correct syntax?  The way you wrote it, it 
looks like you tried:

$ set LC_ALL='C'

But that is neither sh (export LC_ALL=C) nor csh (setenv LC_ALL C) 
syntax.  And your problem is absolutely explained by locale, and would 
indeed be "solved" if you indeed had set LC_ALL=C like you meant to do.

-- 
Eric Blake   eblake <at> redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

[Message part 3 (message/rfc822, inline)]
From: Sean Sun <sean.x.sun <at> gmail.com>
To: Bug-coreutils <at> gnu.org
Subject: sort 8.5 bug?
Date: Thu, 22 Sep 2011 13:55:05 -0700 (PDT)
#########################################################
Ubuntu 11.04
2.6.38-11-generic-pae

sort --version
sort (GNU coreutils) 8.5
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Mike Haertel and Paul Eggert.

##########################################################
I created two testing files: File_A and File_B.

cat File_​A
.
BAD.

sort File_A
.
BAD.

cat File_​B
.s
BAD.s

sort File_B
BAD.s
.s

So basi­cally, append­ing a let­ter after ‘.’ would reverse the sort order.
That doesn't look quite right. Is there an explanation for this behavior?
I've tried the same on a Mac, and their sort (5.93) woks just fine.

I've also tried set LC_ALL='C'. Just in case it's a funky locale problem,
but didn't make a difference.

-- 
View this message in context: http://old.nabble.com/sort-8.5-bug--tp32503840p32503840.html
Sent from the Gnu - Coreutils - Discuss mailing list archive at Nabble.com.




This bug report was last modified 13 years and 245 days ago.

Previous Next


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