Hi dilip.renkila

In addition to what Athanasius has outlined re: your inner-most foreach loop and Laurent_R re: your initial data structure, here is a snippet of code and its output to help with the syntax of sort

Code

#!/usr/bin/perl -lw use strict; my %update = ( '2' => { '25' => { 'i' => 5000025, 'o' => 5000025 }, '4' => { 'o' => 5000004, 'i' => 5000004 }, '19' => { 'i' => 5000019, 'o' => 5000019 }, '2' => { 'o' => 5000002, 'i' => 5000002 }, }, '6' => { '7' => { 'i' => 5000007, 'o' => 5000007 }, '13' => { 'o' => 5000013, 'i' => 5000013 }, } ); for my $id (sort {$a <=> $b} keys %update) { for my $index (sort {$a <=> $b} keys %{$update{$id}}) { print "$update{$id}->{$index}->{i},$update{$id}->{$index}->{o}"; } } __END__

Output

5000002,5000002 5000004,5000004 5000019,5000019 5000025,5000025 5000007,5000007 5000013,5000013

Good Luck!


In reply to Re: sorting hash of hashes by shadowsong
in thread sorting hash of hashes by dilip.renkila

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.