I have the following table being generated...
Key1 Key2 Value -------------------------------------- red bike 5 red car 4 red shoes 20 yellow shoes 1 yellow skates 1000
What I want to do is have the same table but sorted on the Value column. Therefore I would see 1000 at the top and then 20 next, etc... I read from a delimited file and create a hash of a hash of an array. The array holds the value, a counter, which is incremented within a while loop with the following line
while (<>){ ... $hash{key1}{key2}[0]++; ... }
I currently print the table above with the following:
for $colour (sort keys %hash){ for $device (sort keys %{ $hash{$colour}}){ printf("\n%-55s %-55s %-40s", $colour, $device, $hash{$colour}{$device}[0] ); } }
How do I print the table by sorting strictly on the value?

In reply to Sorting multi-hash values by papai

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.