bug-coreutils
[Top][All Lists]
Advanced

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

Re: New sort(1) feature -- sort by length


From: Eric Blake
Subject: Re: New sort(1) feature -- sort by length
Date: Thu, 16 Jul 2009 22:13:38 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.22) Gecko/20090605 Thunderbird/2.0.0.22 Mnenhy/0.7.6.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Eric Blake on 7/16/2009 10:07 PM:
> According to Ethan Baldridge on 7/16/2009 3:06 PM:
>> I had a list to sort at work today that needed to be in the format "A B
>> C D E... AA BB CC DD" but sort(1) only returns results as "A AA B BB C
>> CC".
> 
> Thanks for the ideas; it is especially nice when ideas are accompanied by
> a patch.  However,...
> 
> sort is already quite powerful.  I'm not sure we need a new command line
> option unless we can prove there is no way to do what you want with the
> existing options.  Taking your example, here's a length-based sort:

It would help if I posted the correct example (I was playing around with
several alternative command lines, to prove that the notion of choosing
where a key starts or ends can be used to simulate lengths):

$ echo AB A B C D E AA BB CC DD EE | tr ' ' '\n' | sort -k1.2,1 -k1.1,1
A
B
C
D
E
AA
AB
BB
CC
DD
EE

Also, I do agree that this approach is a bit limited, in that it requires
as many keys as you anticipate length of the field being sorted, so that
does give your proposal a bit of strength.  At any rate, I'll let others
chime in now on the merits of the proposal.

Also, your patch is not trivial.  Before we could even consider it as-is,
we would need copyright assignment (it also needs accompanying
documentation and regression tests, but we may be able to help with those
if we get the bigger hurdle of assignment out of the way).  Is this still
something you are interested in pursuing?

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEUEARECAAYFAkpf+nIACgkQ84KuGfSFAYAbeACUDaZQBp147fzv7MzoHL9yUk1c
WQCfb6b6m74YXCTtn112jR5YhsD1Uqk=
=xcTd
-----END PGP SIGNATURE-----




reply via email to

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