This will sort on the length of the first key found in each inner hash, then ASCIIbetically on the keys of the main HoHoA for ties:
my @sorted = map {substr $_,2} sort map { pack 'na*', length((%{$HoHoA{$_}})[0]), $_ } keys %HoHoA;

This is a Guttman-Rosler Transform - it packs the length of the first key of each inner hash (assumption: each inner hash has all keys the same length - you can't guarantee to get an AA.. key rather than a BB.. key as the `first') into 2 bytes in network order (assumption: no inner hash key has length >65535) and appends the main hash key.

The resulting list of strings can be sorted by the fast default sort and the substr throws away the two-byte length marker, leaving just the keys.

HTH

Jonathan


In reply to Re: Sorting HoHoA based on Length of Second Key by Anonymous Monk
in thread Sorting HoHoA based on Length of Second Key by Anonymous Monk

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.