[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: non-stable sort with > 1 key
From: |
Eric Blake |
Subject: |
Re: non-stable sort with > 1 key |
Date: |
Sat, 06 Oct 2007 17:33:54 -0600 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070728 Thunderbird/2.0.0.6 Mnenhy/0.7.5.666 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to Greg Minshall on 10/6/2007 4:28 PM:
> hi. i want to sort first alphabetically on field 1 then numerically on field
> 2 (so, field 2 is the secondary key). it seems that when running, field 2
> becomes the major key.
Not a bug in sort, but in your usage patterns.
>
> i've tried:
> sort -s +1 -n +2
> sort -s +1 -s -n +2
> sort -s +1 -sn +2
> sort -n -s +1 -s +2
> sort -k1 -s -k2n
All of these have the same property - you specified the start, but not the
end, of the key - by default, sort assumes that the key continues to the
end of the line unless you tell it otherwise.
Try 'sort -k1,1 -k2,2n' instead.
>
> ps -- when did the "+m.n" format become deprecated? Posix? or...?
Yes - POSIX 2001 removed support for it. Read more about it in the
coreutils NEWS file, as well as the info pages.
- --
Don't work too hard, make some time for fun as well!
Eric Blake address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHCBti84KuGfSFAYARAgatAJ97iemkqsdS/uzxvgpZGchT53SIYwCgqcwH
k4WTEoItvGhqtXAagsvABhQ=
=9OOu
-----END PGP SIGNATURE-----