in reply to Custom Sort An AoA
The general trick is to append your additional sort criteria to the sort block.
@list= sort { @$a <=> @$b || ... secondary criterion ... || ... tertiary criterion ... } @list;
So all that remains is to find the appropriate expression to find and compare the last elements of each array:
$a->[-1] cmp $b->[-1] # untested
Taken together, your sort expression would be
@list= sort { @$a <=> @$b || $a->[-1] cmp $b->[-1] } @list;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Custom Sort An AoA
by Limbic~Region (Chancellor) on Apr 01, 2014 at 17:09 UTC |
In Section
Seekers of Perl Wisdom