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:

c:\@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], ]
The statement
    my @AoA = (\@ra_1, \@ra_2, \@ra_3, \@ra_4);
can also be written
    my @AoA = \(@ra_1, @ra_2, @ra_3, @ra_4);
for the same effect; the second form is just a short-hand version of the first.

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.


In reply to Re: multiple array processing by AnomalousMonk
in thread multiple array processing by f77coder

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.