⭐ in reply to How do I do a complex sort on an array?
@sortedarray= map{$_->[0]} # return an array that only contains the original value +s (now sorted) # sort on $computedsortval # you use 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 #this map block computes the value you're going to sort on #and places it in $computedsortval map{ #calculate $computedsortval [$_,$computedsortval]; } @origarray;
|
---|