GNU bug report logs - #23673
wrong sorting order

Previous Next

Package: coreutils;

Reported by: alainm <alain.miniussi <at> oca.eu>

Date: Wed, 1 Jun 2016 15:33:01 UTC

Severity: normal

Tags: notabug

Done: Assaf Gordon <assafgordon <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 23673 in the body.
You can then email your comments to 23673 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#23673; Package coreutils. (Wed, 01 Jun 2016 15:33:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to alainm <alain.miniussi <at> oca.eu>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Wed, 01 Jun 2016 15:33:01 GMT) Full text and rfc822 format available.

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

From: alainm <alain.miniussi <at> oca.eu>
To: bug-coreutils <at> gnu.org
Subject: wrong sorting order
Date: Wed, 1 Jun 2016 15:16:55 +0200
Hi

I need to perform a sort based on the first 3 indexes of a line (sort  
-k 1,3 -n truc.lst):

The 0 coordinates are not placed before the 2 coordinates, it looks like 
the spaces are ignore:

[alainm <at> tagir 1src]$ more truc.lst
2  9 32 27 1.3925940E-13
0 29 33 33 0.0000000E+00
0 29 33  1 0.0000000E+00
0 29 33  1 0.0000000E+00
0 29 33  1 0.0000000E+00
2  9 32 19 0.0000000E+00
2  9 32 19 0.0000000E+00
2  9 32 27 0.0000000E+00
0 29 33  9 0.0000000E+00
0 29 33  9 0.0000000E+00
0 29 33  9 0.0000000E+00
2  9 32 35 1.4211723E-13
2  9 32 19 1.3592767E-13
0 29 33  1 1.5564060E-13
2  9 32 43 1.4770083E-13
0 29 33 17 0.0000000E+00
0 29 33 17 0.0000000E+00
2  9 32 11 8.4966119E-14
0 29 33 25 0.0000000E+00
2  9 32  3 0.0000000E+00
2  9 32  3 0.0000000E+00
2  9 32  3 0.0000000E+00
2  9 32  3 4.8971061E-14
0 29 33 41 0.0000000E+00
2  9 32 11 0.0000000E+00
2  9 32 11 0.0000000E+00
2  9 32 11 0.0000000E+00
[alainm <at> tagir 1src]$  sort  -k 1,3 -n truc.lst
2  9 32 11 0.0000000E+00
2  9 32 11 0.0000000E+00
2  9 32 11 0.0000000E+00
2  9 32 11 8.4966119E-14
2  9 32 19 0.0000000E+00
2  9 32 19 0.0000000E+00
2  9 32 19 1.3592767E-13
2  9 32 27 0.0000000E+00
2  9 32 27 1.3925940E-13
2  9 32  3 0.0000000E+00
2  9 32  3 0.0000000E+00
2  9 32  3 0.0000000E+00
2  9 32  3 4.8971061E-14
2  9 32 35 1.4211723E-13
2  9 32 43 1.4770083E-13
0 29 33  1 0.0000000E+00
0 29 33  1 0.0000000E+00
0 29 33  1 0.0000000E+00
0 29 33  1 1.5564060E-13
0 29 33 17 0.0000000E+00
0 29 33 17 0.0000000E+00
0 29 33 25 0.0000000E+00
0 29 33 33 0.0000000E+00
0 29 33 41 0.0000000E+00
0 29 33  9 0.0000000E+00
0 29 33  9 0.0000000E+00
0 29 33  9 0.0000000E+00
[alainm <at> tagir 1src]$

[alainm <at> tagir 1src]$ sort --version
sort (GNU coreutils) 8.4
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.

Cheer

Alain





Information forwarded to bug-coreutils <at> gnu.org:
bug#23673; Package coreutils. (Wed, 01 Jun 2016 15:45:01 GMT) Full text and rfc822 format available.

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

From: Assaf Gordon <assafgordon <at> gmail.com>
To: alainm <alain.miniussi <at> oca.eu>, 23673 <at> debbugs.gnu.org
Subject: Re: bug#23673: wrong sorting order
Date: Wed, 1 Jun 2016 11:44:47 -0400
tag 23673 notabug
close 23673
stop

Hello Alain,

On 06/01/2016 09:16 AM, alainm wrote:
> I need to perform a sort based on the first 3 indexes of a line (sort -k 1,3 -n truc.lst):
>
> The 0 coordinates are not placed before the 2 coordinates, it looks like the spaces are ignore:
[...]
>
> [alainm <at> tagir 1src]$  sort  -k 1,3 -n truc.lst

To sort multiple numeric fields, use separate "-k" parameters, like so:

    sort -k1,1 -k2,2 -k3,3 -n truc.list

If in the future you wish to combine different ordering (e.g. numeric and alphanumeric, or some fields in reverse order),
consider specifying the order in each key instead of globally:

    sort -k1n,1 -k2nr,2 -k3n,3 truc.list

> [alainm <at> tagir 1src]$ sort --version
> sort (GNU coreutils) 8.4

If you upgrade to coreutils version 8.6 or later, sort will accept '--debug' option, which will help you troubleshoot such cases:

    $ sort --debug -k 1,3 -n truc.lst
    sort: using ‘en_US.UTF-8’ sorting rules
    sort: key 1 is numeric and spans multiple fields
    [...]


I'm marking this bug as done, but discussion can continue by replying to this thread.

regards,
 - assaf






Information forwarded to bug-coreutils <at> gnu.org:
bug#23673; Package coreutils. (Wed, 01 Jun 2016 15:57:01 GMT) Full text and rfc822 format available.

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

From: alainm <alain.miniussi <at> oca.eu>
To: 23673 <at> debbugs.gnu.org
Subject: Re: bug#23673: wrong sorting order
Date: Wed, 1 Jun 2016 17:56:14 +0200
Thank you Assaf for the clarification.

Alain


On 01/06/2016 17:44, Assaf Gordon wrote:
> tag 23673 notabug
> close 23673
> stop
>
> Hello Alain,
>
> On 06/01/2016 09:16 AM, alainm wrote:
>> I need to perform a sort based on the first 3 indexes of a line (sort 
>> -k 1,3 -n truc.lst):
>>
>> The 0 coordinates are not placed before the 2 coordinates, it looks 
>> like the spaces are ignore:
> [...]
>>
>> [alainm <at> tagir 1src]$  sort  -k 1,3 -n truc.lst
>
> To sort multiple numeric fields, use separate "-k" parameters, like so:
>
>     sort -k1,1 -k2,2 -k3,3 -n truc.list
>
> If in the future you wish to combine different ordering (e.g. numeric 
> and alphanumeric, or some fields in reverse order),
> consider specifying the order in each key instead of globally:
>
>     sort -k1n,1 -k2nr,2 -k3n,3 truc.list
>
>> [alainm <at> tagir 1src]$ sort --version
>> sort (GNU coreutils) 8.4
>
> If you upgrade to coreutils version 8.6 or later, sort will accept 
> '--debug' option, which will help you troubleshoot such cases:
>
>     $ sort --debug -k 1,3 -n truc.lst
>     sort: using ‘en_US.UTF-8’ sorting rules
>     sort: key 1 is numeric and spans multiple fields
>     [...]
>
>
> I'm marking this bug as done, but discussion can continue by replying 
> to this thread.
>
> regards,
>  - assaf
>
>





Added tag(s) notabug. Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Sun, 28 Oct 2018 06:04:01 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 23673 <at> debbugs.gnu.org and alainm <alain.miniussi <at> oca.eu> Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Sun, 28 Oct 2018 06:04:01 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 25 Nov 2018 12:24:11 GMT) Full text and rfc822 format available.

This bug report was last modified 6 years and 213 days ago.

Previous Next


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