[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#14988: sort enhancement request
From: |
Eric Blake |
Subject: |
bug#14988: sort enhancement request |
Date: |
Tue, 30 Jul 2013 16:43:26 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 |
On 07/30/2013 04:33 PM, Eric Blake wrote:
> It SOUNDS like you are merely asking for a stable sort option. Have you
> tried the -s/--stable option? That effectively adds an invisible key of
> last resort that says if two lines otherwise compare equal, sort them so
> that the line occurring first in input also occurs first in output.
An alternative view of how -s works (that more closely matches what you
will see in 'sort --debug' output) is that POSIX requires that 'sort'
behave as if a key of -k1 were always the last key present (if two lines
otherwise compare equal, sort them by a strcoll() comparison of the
entire line), where -s is the GNU extension that disables this POSIX
implicit full-line sort key, so that you are left with a stable sort.
Since 'adding an option to remove a key' sounds a little fishy on the
surface, you can see why I gave my first explanation instead. But at
the end of the day, all that matters is the result, so pick whichever
mental representation you find easier to understand :)
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature