my $rHash = \%hash; for my $k1 = (sort keys %$rHash) #outer key, this works