Hi All, How would I sort this hash in a hash by VAR1 keys and then VAR2 keys.

I have the following:

sub printIndex { for my $book ( sort keys %ibIndex ) { for my $keyword ( keys( %{ $ibIndex{ $book } } ) { my $pages = join( ', ', @{ $ibIndex{ $book }->{ $keyword } + } ); } } }
$VAR1 = 'Book 3'; $VAR2 = { 'wormhole' => [ 150 ], 'World Wide Web (WWW)' => [ 75, 137, 153 ], 'Wigner, Eugene P. (1902-1995)' => [ 200, 200, 203, 208 ], 'World War II (WWII)' => [ 127 ], 'Work and play' => [ 235 ] }; $VAR3 = 'Book 1'; $VAR4 = { 'wormhole' => [ 266 ], 'Whistlefield Estate' => [ 64, 73, 74, 96 ], 'wisdom' => [ 134, 140, 161, 210, 240, 58 ], 'Yost, Bill' => [ 75, 88 ], '"winners," evolutionary (see "evolution," "natural selectio +n")' => [ + 198, + 199, + 226, + 2 + ], 'Wigner, Eugene P. (1902-1995)' => [ 32 ] }; $VAR5 = 'Book 2'; $VAR6 = { 'worldview' => [ 343 ], 'wisdom' => [ 71, 130, 153, 220, 262, 265, 286, 313, 331 ], 'will' => [ 82, 117, 164 ], 'World community' => [ 344 ] };
After all this is over, all that will really have mattered is how we treated each other.

In reply to How do I sort a hash in a hash? by dbmathis

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.