use strict; use warnings; my %hoh_test = ( foo1 => { bar => -0.12697, baz => -0.000398154, }, foo2 => { bar => -4.0183e-05, baz => 0, }, foo3 => { bar => 9.966003977e-06, baz => 0.0001939, }, ); # Sort on $foo decending foreach my $foo ( sort { $b cmp $a } keys %hoh_test ) { # Sort on values decending foreach my $ba ( sort { $hoh_test{$foo}{$b} <=> $hoh_test{$foo}{$a} } keys %{$hoh_test{$foo}} ) { printf "foo: %s, ba: %s, value: %s\n", $foo, $ba, $hoh_test{$foo}{$ba}; } }