[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#23673: wrong sorting order
From: |
Assaf Gordon |
Subject: |
bug#23673: wrong sorting order |
Date: |
Wed, 1 Jun 2016 11:44:47 -0400 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 |
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:
[...]
address@hidden 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
address@hidden 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