my @vals = qw(3 7 5 0 2); my @index = sort{ $vals[ $a ] <=> $vals[ $b ] } 0 .. $#vals; print @index; 3 4 0 2 1