in reply to sorting hashes

not sure what you're doing in the sorting of $k2, the following seem to be what you want (not tested):
my $rHash = \%hash; for my $k1 = (sort keys %$rHash) #outer key, this works { for my $k2 (sort {$a <=> $b} keys %{$rHash->{$k1}}) ) { #display miscellaneous print $k1 $k2; } }

Replies are listed 'Best First'.
Re^2: sorting hashes
by blazar (Canon) on Apr 20, 2005 at 07:39 UTC
    The same cmt I already gave to the OP applies: this can't be what he wants for it wouldn't even compile. Correcting the typo indeed this could be what he wants.

    Oh, and BTW:

    print $k1 $k2;
    Aren't we missing something here too?!?
      Hello again,
      the = sign was a typo that is not present in my original code - sorry about that, same with the print statement - was just to indicate that there was some output.

      The solution was indeed to use sort with just $a and $b - yep, Perl is not my first language.

      Thank you all for the exceptionally quick replies.

      rgds,
      Ole C.
        Hello again,
        the = sign was a typo that is not present in my original code - sorry about that, same with the print statement - was just to indicate that there was some output.
        There's a lesson in this, and an oft advocated one: do not retype code, paste it. (In this case not much harm was being done, but it's a good general rule to stick to, if possible.)