in reply to multiple array processing
1. sort array based on number of elements in each from smallest to largest
Here's something sort of like what I imagine you might want given the preceding array pseudo-code:
The statementc:\@Work\Perl>perl -wMstrict -le "use Data::Dump; ;; my @ra_1 = qw(a b c d); my @ra_2 = (1 .. 9); my @ra_3 = qw(p z e t i u); my @ra_4 = qw(foo bar baz); ;; my @AoA = (\@ra_1, \@ra_2, \@ra_3, \@ra_4); dd \@AoA; ;; my @sorted = sort { @$a <=> @$b } @AoA; dd \@sorted; " [ ["a" .. "d"], [1 .. 9], ["p", "z", "e", "t", "i", "u"], ["foo", "bar", "baz"], ] [ ["foo", "bar", "baz"], ["a" .. "d"], ["p", "z", "e", "t", "i", "u"], [1 .. 9], ]
2. is it possible to sort the sub-arrays by name? then size?
I don't understand what this means. Do you want to sort by the names of the lexical variables? If so, why? Maybe you really want a more complex structure than an array or array-of-arrays, e.g, a data structure. Please see perldsc.
3. to do a random sort by name with (1A,2A…) then (1B,2B,…). ...
Any array can be randomly 'sorted'. See List::Util::shuffle.
I don't really understand the rest of the code you present in the OP.
Update: Many incremental changes. Sorry.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: multiple array processing
by f77coder (Beadle) on Sep 03, 2014 at 04:44 UTC | |
by AnomalousMonk (Archbishop) on Sep 03, 2014 at 05:52 UTC | |
by f77coder (Beadle) on Sep 06, 2014 at 23:28 UTC | |
by NetWallah (Canon) on Sep 03, 2014 at 05:16 UTC | |
by f77coder (Beadle) on Sep 06, 2014 at 23:25 UTC |