in reply to
Sorting multi dimensional arrays
my $sample= [ [5,7,2], [9,4,8], [1,6,3] ];
my @widths= map 0+@$_, @$sample;
my @sort= sort map @$_, @$sample;
$sample= [ map { [ splice @sort, 0, $_ ] } @widths ];
But if you really wanted to not pull it apart to sort it:
use mapcar;
my $sample= [ [5,7,2], [9,4,8], [1,6,3] ];
my @refs= sort {$$a cmp $$b} map \(@$_), @$sample;
mapcar {
my( $ref, $val )= @_;
$$ref= $val;
} \@refs, [ map $$_, @refs ];
Which requires that you grab my mapcar.
-
tye
(but my friends call me "Tye")