Re: sort by line length

2007-04-24 Thread Eric Blake
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

Re: sort by line length

2007-04-24 Thread Jim Meyering
Georg Müller [EMAIL PROTECTED] 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

Re: sort by line length

2007-04-24 Thread Pádraig Brady
Georg Müller wrote: Dear coreutils team, 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. That seems like a very specific need which is probably best fulfilled with a

Re: sort by line length

2007-04-24 Thread Brian Dessent
Jim Meyering wrote: 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 a | fmt -1 \ | perl -ne 'push @line, $_;sub END{print sort {length $a=length $b} @line}' 1 aa 938 four a Not to derail on

Re: sort by line length

2007-04-24 Thread Andreas Schwab
Georg Müller [EMAIL PROTECTED] writes: I would like to see a sort by line length in the sort tool. awk '{ print length(), $0 }' input | sort -k1,1n | cut -d' ' -f2- output Andreas. -- Andreas Schwab, SuSE Labs, [EMAIL PROTECTED] SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg,

Re: sort by line length

2007-04-24 Thread Georg Müller
I know that I can solve this by these combinations, but having a -l flag for sort would be much shorter to write and I am not so familiar with perl. It was just an idea to make things easier, if you don't like it, ignore it. I need it atm for bug fixing other stuff, but searched for that a time