bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#6790: Problem(bug?) with basic sort command in Linux


From: Erik Auerswald
Subject: bug#6790: Problem(bug?) with basic sort command in Linux
Date: Wed, 4 Aug 2010 13:12:05 +0200
User-agent: Mutt/1.5.18 (2008-05-17)

Hi George,

On Wed, Aug 04, 2010 at 01:32:55AM +0530, George Thomas Irimben (georgeti) 
wrote:
> I would like to report a problem(bug?) I am facing with sort command in
> Linux.
> 
> Sorting of a simple text file using simple sort command is giving me
> incorrect result.
> 
> Here is the problem:
> 
> Text file to sort has 3 lines
> my-lnx7% cat y
> abc/d,ABC
> abc/,XYZ
> abc/o,MNO
> 
> sort command from Linux is giving me below result(According to me, this
> result is incorrect)
> 
> my-lnx7% sort y
> abc/d,ABC
> abc/o,MNO
> abc/,XYZ
> 
> But, result expected is as below. Because "," is ahead of "d" in ASCII
> table. 
> Same found working on Unix using same input file, same command line.
> 
> abc/,XYZ
> abc/d,ABC
> abc/o,MNO
> 
> 
> Pls let me know if this is a problem in Linux or I am missing something.

You missed the effects of locale settings (see
http://www.gnu.org/software/coreutils/faq/coreutils-faq.html#Sort-does-not-sort-in-normal-order_0021).

$ printf "abc/d,ABC\nabc/,XYZ\nabc/o,MNO\n" | LC_COLLATE=en_US.UTF-8 sort
abc/d,ABC
abc/o,MNO
abc/,XYZ
$ printf "abc/d,ABC\nabc/,XYZ\nabc/o,MNO\n" | LC_COLLATE=C sort 
abc/,XYZ
abc/d,ABC
abc/o,MNO

Erik
-- 
If you're willing to restrict the flexibility of your approach,
you can almost always do something better.
                        -- John Carmack





reply via email to

[Prev in Thread] Current Thread [Next in Thread]