in reply to sorting multidimensional arrays
my @unsorted = ( [8,9,10], [6,5,4], [7,8,9] ); foreach my $inner(@unsorted) { $inner = [ reverse @{ $inner } ]; }
This works because of the special aliasing nature of a for-loop. The loop variable $inner is an alias for each array reference, so changing it results in changing the array reference inside @unsorted.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: sorting multidimensional arrays
by Roy Johnson (Monsignor) on Mar 15, 2005 at 22:59 UTC |