mock5c
asked on
get sorted column for 2D array
Need a one-liner for extracting a single column from a 2D array, provided the index. The returned array should be sorted (numerically).
I found code on EE for sorting a single column but it returns the entire 2D array with column i sorted.
@ary = (
[4,5,8],
[2,10,5],
[8,13,7]
);
$i = 0;
@sorted = sort {$a->[$i]<=>$b->[$i]} @ary;
I just want column i sorted and returned.
I found code on EE for sorting a single column but it returns the entire 2D array with column i sorted.
@ary = (
[4,5,8],
[2,10,5],
[8,13,7]
);
$i = 0;
@sorted = sort {$a->[$i]<=>$b->[$i]} @ary;
I just want column i sorted and returned.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER