in reply to reading array from the last into begining
Q: How do I sort an array in reverse order (descending instead of ascending):foreach my $element ( reverse @array ) { print "$element\n"; }
or@sorted_array = reverse sort @array;
(That's for numeric values. For strings try....)@sorted_array = sort { $b <=> $a } @array;
Hmm.... a few others with map and unshift:@sorted_array = sort { $b cmp $a } @array;
or....@reversed_array = map { $array[$_] } reverse 0..$#array;
foreach $element ( @array ) { unshift @reversed_array, $element; }
Have at it!
Dave
|
|---|