#!/usr/bin/perl -w use strict; my %hoh_test; $hoh_test{foo1}{bar} = -0.12697; $hoh_test{foo1}{baz} = -0.000398154; $hoh_test{foo2}{bar} = -4.0183e-05; $hoh_test{foo2}{baz} = 0; $hoh_test{foo3}{bar} = 9.966003977e-06; $hoh_test{foo3}{baz} = 0.0001939; # sort descending by value foreach my $foo (keys(%hoh_test)) { foreach my $ba (sort {$hoh_test{$foo}{$b} <=> $hoh_test{$foo}{$a}} keys(%{$hoh_test{$foo}})) { printf("foo: $foo, ba: $ba, value: %s\n", $hoh_test{$foo}{$ba}); } }