bug-coreutils
[Top][All Lists]
Advanced

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

Re: sort by line length


From: Jim Meyering
Subject: Re: sort by line length
Date: Tue, 24 Apr 2007 15:01:10 +0200

Georg Müller <address@hidden> wrote:
> I would like to see a "sort by line length" in the sort tool.
>
> Is anything like this planned.
> It seems easy to implement.
> I could also write the code for that, if you wish.

You can do this in perl (or awk, ruby, etc) as a one-liner,
so it may not be worth adding to a C application:

echo 1 938 four aa aaaaa | fmt -1 \
  | perl -ne 'push @line, $_;sub END{print sort {length $a<=>length $b} @line}'
1
aa
938
four
aaaaa

Is that good enough for you?




reply via email to

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