On Tue, 8 Mar 2016 13:29:40 -0800 Kenneth Wolcott <kennethwolc...@gmail.com> wrote:
> How do I call the built-in Perl sort function on an array of strings > where the string is composed of one or more digits, followed by a tab > which is followed by a string and I want the results to be sorted in > reverse numeric order? The best thing to do is write a sortkey function to extract the keys: sub sortkey { my $value = shift @_; return split /\t/, $value, 2; } my @sorted = map { $_->[0] } sort { $b->[1] <=> $a->[1] || $a->[2] cmp $b->[2] } map { [ $_. sortkey( $_ ) ] } @list; -- Don't stop where the ink does. Shawn -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/