bug-coreutils
[Top][All Lists]
Advanced

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

bug#6393: The meaning of --key of sort command?


From: Eric Blake
Subject: bug#6393: The meaning of --key of sort command?
Date: Thu, 10 Jun 2010 11:01:51 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100430 Fedora/3.0.4-3.fc13 Lightning/1.0b2pre Mnenhy/0.8.2 Thunderbird/3.0.4

On 06/10/2010 10:39 AM, Peng Yu wrote:
> Hi,
> 
> I don't think that I completely understand what key means. In the
> following example, I thought that --key=2 should order the lines by
> the 2nd letter in each line without reordering the lines with the same
> 2nd letter. But it turns out my understanding is not correct. For
> example, "u a" was before "a a" sorting, but "u a" is after "a a"
> after sorting.

'--key=2' implies a primary sort key from the second field (not second
letter), through the end of the line, with a secondary sort key of the
entire line.  '--key=2,2' implies a primary sort key of just the second
field, with a secondary sort key of the entire line.  You want
'--key=2,2 --stable', which disables the secondary sort over the entire
line.

-- 
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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