McDarren's response is probably correct but, just to elaborate further...

The first thing you should note is that your sorting hashes, that is, they're being demoted to mere scalars in order to be sorted. The scalar representation of a hash is a rather useless value that shows some internal statistics about the hash. Consider this code:

my %foo =( '11' =>{ '4'=>'Four', }, '33' =>{ '1'=>'One', }, '2' =>{ '2' => 'Two', }, ); my $ref_HoH = \%foo; my @sorted = sort { my $c = %{ $ref_HoH->{$a} }; my $d = %{ $ref_HoH->{$b} }; print "comparing $c to $d...\n"; $c <=> $d; } keys %$ref_HoH; __END__ comparing 1/8 to 1/8... comparing 1/8 to 1/8... comparing 1/8 to 1/8...

See what's happening? (Also note that I've fixed your incorrect usage of the reference; under warnings you would also had spotted the error). You seem to want to sort by the keys or the values of the inner hashes. In fact the order you want is also the one you'd get if you sorted the inner values reverse-alphabetically. But that isn't clear in your post.

--
David Serrano


In reply to Re: Sorting a Hash of Hashes by Hue-Bond
in thread Sorting a Hash of Hashes 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.