Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I get this:%foo =( '11' =>{ '4'=>'Four', }, '33' =>{ '1'=>'One', }, '2' =>{ '2' => 'Two', }, ); my $ref_HoH = \%foo; for my $k ( sort {%{ $ref_HoH{$a} } <=> %{ $ref_HoH{$b} } }keys + %$ref_HoH ) { print "$k\n"; for my $j ( sort keys %{$ref_HoH->{ $k }} ) { print "\t$j\n"; } }
What should I do to get this code to print my keys like so:33 1 11 4 2 2
Thank you guys.2 11 33
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sorting a Hash of Hashes
by McDarren (Abbot) on Jul 09, 2006 at 02:35 UTC | |
|
Re: Sorting a Hash of Hashes
by HuckinFappy (Pilgrim) on Jul 09, 2006 at 03:01 UTC | |
|
Re: Sorting a Hash of Hashes
by Hue-Bond (Priest) on Jul 09, 2006 at 03:08 UTC | |
|
Re: Sorting a Hash of Hashes
by johngg (Canon) on Jul 09, 2006 at 12:14 UTC | |
by Anonymous Monk on Jul 09, 2006 at 15:11 UTC |