or if you feel so inclined to do a schwartzian type transform (used when an expensive function is used to evaluate order):my @sorted_by_length = sort { length($a) <=> length($b) } @elements;
HTHmy @sorted_by_length = map { $_->[0] } sort { $a->[1] <=> $b->[1] } map { [ $_, length($_) ] } @elements
-enlil
In reply to Re: Sort by string length
by Enlil
in thread Sort by string length
by EchoAngel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |