You don't exactly tell us what you're expecting for output... nor is your example values enough to indicate certain behaviours even if you were to give us the output for the above HoH.
I'm going to take a quick guess:
#!/usr/bin/perl
use strict;
use warnings;
my %HoH = ( www => { wwe => 1, wte => 2, wee => 0} );
for my $outter (sort keys %HoH)
{
for my $inner (sort { $HoH{$outter}{$a} <=> $HoH{$outter}{$b} } ke
+ys %{$HoH{$outter}})
{
print "${outter}::$inner = $HoH{$outter}{$inner}\n";
}
}
producing:
$ perl ./x.pl
www::wee = 0
www::wwe = 1
www::wte = 2
Probably not entirely what you want, but I can't be sure.
Update: Probably closer to what you want:
#!/usr/bin/perl
use strict;
use warnings;
my %HoH = (
www => { wwe => 11, wte => 21, wee => 0},
zzz => { zze => 15 },
);
my @keys = sort {
$HoH{$a->[0]}{$a->[1]} <=>
$HoH{$b->[0]}{$b->[1]}
} map {
my $outter = $_;
map {
[ $outter, $_ ]
} keys %{$HoH{$outter}};
} keys %HoH;
for (@keys)
{
print( (join '::', @$_), ' = ', $HoH{$_->[0]}{$_->[1]}, "\n");
}
which produces:
$ perl ./x.pl
www::wee = 0
www::wwe = 11
zzz::zze = 15
www::wte = 21
I'm sure one of the other monks has a more generic solution here (probably either TheDamian or Merlyn) for handling arbitrary depths... |