Can you please assign / push $_ value in array ?

I think tybalt89 was just trying to tie  %hash1 into a solution in line with the structures given in your OP. I, myself, don't understand the relation of the  %hash1 and  %hash2 hashes: they seem essentially identical. See johngg's post for another approach to trying to tie these two hashes together meaningfully.

Separating out the elements a bit, see if this is clearer:

c:\@Work\Perl\monks>perl -wMstrict -le "my %hash1 = map { $_ => 1 } 1 .. 5; ;; my %hash2; $hash2{'1'}{key} = 'a'; $hash2{'2'}{key} = 'b'; $hash2{'3'}{key} = 'a'; $hash2{'4'}{key} = 'a'; $hash2{'5'}{key} = 'b'; ;; my @sorted_top_level_hash1_keys = map $_->[0], sort { $a->[1] cmp $b->[1] or $a->[0] <=> $b->[0] } map [ $_, $hash2{$_}{'key'} ], keys %hash1 ; print qq{sorted top-level %hash1 keys: (@sorted_top_level_hash1_keys) +}; ;; for my $stlh1k (@sorted_top_level_hash1_keys) { print qq{key $stlh1k and $hash2{$stlh1k}{key}} } " sorted top-level %hash1 keys: (1 3 4 2 5) key 1 and a key 3 and a key 4 and a key 2 and b key 5 and b


Give a man a fish:  <%-{-{-{-<


In reply to Re^3: hash sort by AnomalousMonk
in thread hash sort by Anonymous Monk

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.