in reply to Re^2: Custom Sort An AoA
in thread Custom Sort An AoA
If all the data were numeric and limited in length, you could zero-pad it before the join and then CMP it since <=> will probably explode on longer arrays.
If you need it to be fully generic, you could always break down and make the sort block be a complex sub that loops over the elements and returns once it finds a difference.
sub sortIt { my $result = @$a <=> @$b; my $idx = $#$a; while (!$result && $idx >=0) { $result = $a->[$idx] cmp $b->[$idx]; $idx--; } return $result; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Custom Sort An AoA
by LanX (Saint) on Apr 01, 2014 at 18:42 UTC | |
by Limbic~Region (Chancellor) on Apr 02, 2014 at 12:11 UTC | |
|
Re^4: Custom Sort An AoA
by Limbic~Region (Chancellor) on Apr 01, 2014 at 17:54 UTC | |
by shmem (Chancellor) on Apr 02, 2014 at 08:20 UTC | |
by Limbic~Region (Chancellor) on Apr 02, 2014 at 12:07 UTC |