in reply to How do I record in what order a sort was preformed
#initialize array @array = (12,7,4); $i=0; foreach (@array) { #Throw in a hash to look up in a second $hash{$_} = $i; $i++; } #sort it, loop through, and look up from hash from above foreach (@num_sorted_array = sort { $a <=> $b } @array) { print "$_ came from \$array\[$hash{$_}\]\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: How do I record in what order a sort was preformed
by trs80 (Priest) on Jan 18, 2002 at 04:06 UTC |