http://www.perlmonks.org?node_id=388426


in reply to Sort by string length

my @sorted_by_length = sort { length($a) <=> length($b) } @elements;
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 = map { $_->[0] } sort { $a->[1] <=> $b->[1] } map { [ $_, length($_) ] } @elements
HTH

-enlil