Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Also an ST, but it sorts both levels

#! perl -slw use strict; use Data::Dumper; my $value = 1; ## Set up some test data my %hash = map{ $_ => { map{ $_ => $value++ } map{ my $digit = $_; map{ "$digit.$_" } 'A' .. 'C' } 1 .. 3 } } map{ my $digit = $_; map{ "$digit.$_" } 'A' .. 'C' } 1 .. 3; # print Dumper \%hash; ## Sort and print print for map{ "{$_->[ 0 ]}{$_->[ 1 ]} => $hash{ $_->[ 0 ] }{ $_->[ 1 ] }" } sort { $a->[ 2 ] <=> $b->[ 2 ] || $a->[ 3 ] cmp $b->[ 3 ] || $a->[ 4 ] <=> $b->[ 4 ] || $a->[ 5 ] cmp $b->[ 5 ] } map{ my $key1 = $_; my( $n1, $l1 ) = $key1 =~ m[(^\d+)\.(.*)]; map{ my( $n2, $l2 ) = $_ =~ m[(^\d+)\.(.*)]; [ $key1, $_, $n1, $l1, $n2, $l2 ] } keys %{ $hash{ $_ } } } keys %hash; __OUTPUT__ P:\test>junk {1.A}{1.A} => 1 {1.A}{1.B} => 2 {1.A}{1.C} => 3 {1.A}{2.A} => 4 {1.A}{2.B} => 5 {1.A}{2.C} => 6 {1.A}{3.A} => 7 {1.A}{3.B} => 8 {1.A}{3.C} => 9 {1.B}{1.A} => 10 {1.B}{1.B} => 11 {1.B}{1.C} => 12 {1.B}{2.A} => 13 {1.B}{2.B} => 14 {1.B}{2.C} => 15 {1.B}{3.A} => 16 {1.B}{3.B} => 17 {1.B}{3.C} => 18 {1.C}{1.A} => 19 {1.C}{1.B} => 20 {1.C}{1.C} => 21 {1.C}{2.A} => 22 {1.C}{2.B} => 23 {1.C}{2.C} => 24 {1.C}{3.A} => 25 {1.C}{3.B} => 26 {1.C}{3.C} => 27 {2.A}{1.A} => 28 {2.A}{1.B} => 29 {2.A}{1.C} => 30 {2.A}{2.A} => 31 {2.A}{2.B} => 32 {2.A}{2.C} => 33 {2.A}{3.A} => 34 {2.A}{3.B} => 35 {2.A}{3.C} => 36 {2.B}{1.A} => 37 {2.B}{1.B} => 38 {2.B}{1.C} => 39 {2.B}{2.A} => 40 {2.B}{2.B} => 41 {2.B}{2.C} => 42 {2.B}{3.A} => 43 {2.B}{3.B} => 44 {2.B}{3.C} => 45 {2.C}{1.A} => 46 {2.C}{1.B} => 47 {2.C}{1.C} => 48 {2.C}{2.A} => 49 {2.C}{2.B} => 50 {2.C}{2.C} => 51 {2.C}{3.A} => 52 {2.C}{3.B} => 53 {2.C}{3.C} => 54 {3.A}{1.A} => 55 {3.A}{1.B} => 56 {3.A}{1.C} => 57 {3.A}{2.A} => 58 {3.A}{2.B} => 59 {3.A}{2.C} => 60 {3.A}{3.A} => 61 {3.A}{3.B} => 62 {3.A}{3.C} => 63 {3.B}{1.A} => 64 {3.B}{1.B} => 65 {3.B}{1.C} => 66 {3.B}{2.A} => 67 {3.B}{2.B} => 68 {3.B}{2.C} => 69 {3.B}{3.A} => 70 {3.B}{3.B} => 71 {3.B}{3.C} => 72 {3.C}{1.A} => 73 {3.C}{1.B} => 74 {3.C}{1.C} => 75 {3.C}{2.A} => 76 {3.C}{2.B} => 77 {3.C}{2.C} => 78 {3.C}{3.A} => 79 {3.C}{3.B} => 80 {3.C}{3.C} => 81

Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
"Memory, processor, disk in that order on the hardware side. Algorithm, algoritm, algorithm on the code side." - tachyon

In reply to Re: sorting a complex multidimensional hash by BrowserUk
in thread sorting a complex multidimensional hash by envirodug

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others having an uproarious good time at the Monastery: (2)
    As of 2014-07-30 22:42 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (241 votes), past polls