bug-coreutils
[Top][All Lists]
Advanced

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

Re: sort by line length


From: Eric Blake
Subject: Re: sort by line length
Date: Tue, 24 Apr 2007 06:50:08 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.10) Gecko/20070221 Thunderbird/1.5.0.10 Mnenhy/0.7.5.666

According to Georg Müller on 4/24/2007 6:22 AM:
> Dear coreutils team,
> 
> I would like to see a "sort by line length" in the sort tool.
> 
> Is anything like this planned.

Not really planned, but it doesn't sound all that bad to me.  Submit a
patch for discussion, if you would like.  But it sounds non-trivial (don't
forget the documentation and testsuite), so you will need copyright
assignment on file.

> It seems easy to implement.
> I could also write the code for that, if you wish.

It may be possible to already do this with existing tools, although
certainly not conventional.  For example, it can probably be achieved
already by writing a custom locale that treats all bytes as the same
collation class, so that strcoll then compares according to line length.
Or you could use a series of operations, such as sed to number the lines
and convert all remaining characters to a single character, sort the
converted file by the reduced key, and then use the resulting order of the
line numbers as the directions for which order to retrieve lines from the
original file.

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

Eric Blake             address@hidden

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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