for (sort keys %{$hash{$key}}) { print "nested key: $_ \n"; }