Next | The Perl Hardware Store | DC.pm Version | 41 |
0 1 2 3 4 5 Albert Mark Morton Babe Nat Larry Einstein Dominus Zeemeister Ruth Torkington Wall
Solution: Sort the list of indices into order:
@indices = sort {$last[$a] cmp $last[$b]} (0 .. $#last);
@indices is now 1, 0, 3, 4, 5, 2
Then slice:
@sorted = @first[@indices];
Result: Mark, Albert, Babe, Nat, Larry, Morton.
Next | Copyright © 2003 M. J. Dominus |