Sort the indices by the values of the array elements those indices index:
my @vals = qw(3 7 5 0 2); my @index = sort{ $vals[ $a ] <=> $vals[ $b ] } 0 .. $#vals; print @index; 3 4 0 2 1
In reply to Re: Sorting by Array values, obtaining indices
by BrowserUk
in thread Sorting by Array values, obtaining indices
by PetaMem
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |