cshirky has asked for the wisdom of the Perl Monks concerning the following question:
I want to sort the array so that the longer lines sort to the top, so that an array like
MGORBA@kremvax.ru and if I ever catch MGORBA@kremvax.ru sniffing my under- MGORBA@kremvax.ru (Lucille Ball)so that it comes out
and if I ever catch MGORBA@kremvax.ru sniffing my under- MGORBA@kremvax.ru (Lucille Ball) MGORBA@kremvax.ruIs there a smarter way to do this than
which seems needlessly messy. Is there something simpler? -clay$length = length($scalar); $store{$length} .= "$scalar\n"; for ( sort $b <=> $a ( keys ( %store ))) { print "$store{$_}"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sorting @ary by line length?
by Big Willy (Scribe) on May 25, 2001 at 00:39 UTC | |
by cshirky (Initiate) on May 25, 2001 at 00:44 UTC | |
|
(bbfu) (smarter?) Re: Sorting @ary by line length?
by bbfu (Curate) on May 25, 2001 at 06:49 UTC | |
by merlyn (Sage) on May 26, 2001 at 06:09 UTC |