@arr=(100,20,3,45,1); #To sort the above array I did @index=sort{ $arr2[$a] <=> $arr2[$b] } 0 .. $#arr; print @index; Output: 4 2 1 3 0