in reply to How do I record in what order a sort was preformed

Always a million ways to skin a cat, and here is yet another...

#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"; }


Probably not the most efficient way (as I loop through array twice and throw into / lookup to a hash), but simple enough.

Regards,
nandeya