@sortedarray= map{$_->[0]} # only use one of these sort lines sort{$a->[1] <=> $b->[1]} # this one for numerical sorting sort{$a->[1] cmp $b->[1]} # this one for textual sorting map{ #calculate $computedsortval [$_,$computedsortval]; } @origarray;