in reply to Sorting Arrays
(The first requires the extra varaible, while the second requires you use the array variable twice.)my $i = 0; my @sorted_indicies = map { $_->[1] } sort { $a->[0] <=> $b->[0] } map { [ $_, $i++ ] } @array; # OR my @sorted_indicies = map { $_->[1] } sort { $a->[0] <=> $b->[0] } map { [ $array[$_], $_ ] } (0..$#array);
-----------------------------------------------------
Dr. Michael K. Neylon - mneylon-pm@masemware.com
||
"You've left the lens cap of your mind on again, Pinky" - The Brain
"I can see my house from here!"
It's not what you know, but knowing how to find it if you don't know that's important
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Sorting Arrays
by merlyn (Sage) on Jan 08, 2002 at 21:59 UTC |