in reply to Sort over remaining part of array
Sorting with respect to the first column is a bit more involved compared to your code, see below. Sorting only part of the array can be achieved using array slices:
@AoA = ( [ 0.5, "b1", "c0" ], [ 0.4, "b1", "c1" ], [ 0.7, "b2", "c2" ], [ 0.3, "b3", "c3" ], [ 0.6, "b3", "c4" ], ); @AoA[2..$#AoA] = sort { $a->[0] <=> $b->[0] } @AoA[2..$#AoA]; print Dumper \@AoA;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Sort over remaining part of array
by Laurent_R (Canon) on Nov 12, 2013 at 19:57 UTC | |
Re^2: Sort over remaining part of array
by monkini (Initiate) on Nov 12, 2013 at 11:15 UTC | |
by jethro (Monsignor) on Nov 12, 2013 at 14:23 UTC | |
by hdb (Monsignor) on Nov 12, 2013 at 11:34 UTC | |
by Anonymous Monk on Nov 12, 2013 at 11:27 UTC |
In Section
Seekers of Perl Wisdom