marcos rebelo wrote:

For doing the Sort, you may consider the schwartzian_transform

sub schwartzian_transform(&@) {
   my $compute = shift;
   return map { $_->[1] }
     sort     { $a->[0] cmp $b->[0] }
     map { [ $compute->(), $_ ] } @_;
}

schwartzian_transform { (split /-/, $_)[1] } @array;

More information on:
http://sites.google.com/site/oleberperlrecipes/recipes/01-variables/02-arrays/03-sort-arrays?pli=1

That subroutine has a much too general name, because it only implements one way to create a temporary index (AKA Schwartzian Transform).

See also http://en.wikipedia.org/wiki/Schwartzian_transform
and of course Sort::Maker. http://search.cpan.org/search?q=Sort::Maker

--
Ruud

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to