Is this what you want?
#!/usr/bin/perl -w use strict; my %hash = ( 'c' => { 'e' => '54.9503577512828', '21' => '40.4544882398113', '7' => '13.665886711539', '17' => '26.3268082750993', '2' => '16.4348644122811', '22' => '35.2357587506792', '1' => '29.5471128362965', '18' => '28.8861232027377', '23' => '19.3437720284897', }, 'd' => { '11' => '26.7647206436788', '21' => '19.4128184125387', '7' => '6.89345884629317', '17' => '12.7682648883531', '2' => '8.44015343941174', '22' => '16.9085166076037', '1' => '15.1739716114483', '18' => '13.9203445318945', }, 'b' => { '11' => '11.5303855045498', '21' => '9.28718107649433', '7' => '2.50040155572952', '17' => '5.93010343000324', '2' => '2.86098737229312', } ); foreach my $k1 (sort keys %hash){ print "\n-> $k1\n"; my $count = 0; foreach my $k2 (sort {$hash{$k1}->{$b} <=> $hash{$k1}->{$a} } keys +%{$hash{$k1}} ){ print "--> $k2: $hash{$k1}->{$k2}\n"; last if $count++ > 0; } }

In reply to Re: How to sort Hashes of Hashes and print results in a file by gulden
in thread How to sort Hashes of Hashes and print results in a file by stan131

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.