# here's my test hash my %hash; $hash{"Rock Bands"}{"Smashing Pumpkins"} = "5 stars"; $hash{"Rock Bands"}{"Aerosmith"} = "5 stars"; $hash{"Rock Bands"}{"Foo Fighters"} = "5 stars"; $hash{"Pop Bands"}{"Duran Duran"} = "5 stars"; $hash{"Pop Bands"}{"Blondie"} = "5 stars"; foreach my $key (sort keys %hash) { # this bit sorts ok print "KEY: $key \n"; while (my ($nestedKey, $value) = each %{ $hash{$key} } ) { # but I can't work out how to sort this iteration print "nested key: $nestedKey \n"; } print "-------\n"; }