wolfman77 has asked for the wisdom of the Perl Monks concerning the following question:
The lengths of @{$array[0]} is 4, @{$array[1]} is 6, @{$array[2}] is 2 and @{$array[3]} is 8. I want to sort the array of arrays by the length of the arrays. So that the array now looks like this:my @array = ( ['1', '2', '3', '4'], ['1','2','3','4','5','6'] ['1','2'] ['1','2','3','4','5','6','7','8'] );
my @sortedarray = ( ['1','2','3','4','5','6','7','8'], ['1','2','3','4','5','6'], ['1', '2', '3', '4'], ['1','2'] );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How do I sort an array of arrays by array length
by kcott (Archbishop) on Feb 27, 2014 at 11:32 UTC | |
by wolfman77 (Initiate) on Feb 27, 2014 at 11:37 UTC | |
|
Re: How do I sort an array of arrays by array length
by Corion (Patriarch) on Feb 27, 2014 at 11:28 UTC |