my @indicies = sort { $a[$a] <=> $a[$b] } 0..$#a;
merlyn is sorting a list of integers (0..$#a) corresponding to the indices of the elements of your array @a. Recall that within sort code blocks, $a and $b are special variables representing the two variables to be ordered each time the block is evaluated. So here,
$a[$a] <=> $a[$b] means sort the indices of the array by the contents of its elements.
It's a bit confusing in this case because of the use of @a as your array variable and the use of $a and $b as special variables to sort.
HTH,
Josh
| [reply] [d/l] [select] |
| [reply] |