Hi Monks,
I am working with Hashes of Hashes and need to sort based value.
Here is output of my sort from Dumper
$VAR15 = '9'; $VAR16 = { '11' => '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', }; $VAR17 = '4'; $VAR18 = { '11' => '26.7647206436788', '21' => '19.4128184125387', '7' => '6.89345884629317', '17' => '12.7682648883531', '2' => '8.44015343941174', '22' => '16.9085166076037', '1' => '15.1739716114483', '18' => '13.9203445318945', }; $VAR19 = '3'; $VAR20 = { '11' => '11.5303855045498', '21' => '9.28718107649433', '7' => '2.50040155572952', '17' => '5.93010343000324', '2' => '2.86098737229312', };
Now in this each Hash key the number of values varies.
First Key 1 has 11,21,7,17,2,22,1,18,23(where 11,21 are doc Id and each doc Id has value)
Second Key 2 has 11,21,7,17,2,22,1,18 (where 11,21 are doc Id and each doc Id has value)
I need 2 things
1) I need to sort based on document value for each key
2) Get the top 2 documents with highest docment value for each key
Your help is appreciated.
Thanks,
Stan

In reply to 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.