my @sorted_indices = sort { $array[$a] <=> $array[$b] } (0..$#array); # If you need to get back the sorted array, use this # without the extra sort step. my @sorted_array = map { $array[$_] } @sorted_indices;