GNU bug report logs - #14988
sort enhancement request

Previous Next

Package: coreutils;

Reported by: Danny Nicholas <danny.nicholas <at> pinnacledatasystems.com>

Date: Tue, 30 Jul 2013 21:45:02 UTC

Severity: wishlist

Tags: moreinfo, notabug

Done: Eric Blake <eblake <at> redhat.com>

Bug is archived. No further changes may be made.

Full log


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

From: Eric Blake <eblake <at> redhat.com>
Cc: Danny Nicholas <danny.nicholas <at> pinnacledatasystems.com>,
 14988 <at> debbugs.gnu.org
Subject: Re: bug#14988: sort enhancement request
Date: Tue, 30 Jul 2013 16:43:26 -0600
[Message part 1 (text/plain, inline)]
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 (application/pgp-signature, attachment)]

This bug report was last modified 12 years and 16 days ago.

Previous Next


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