in reply to sort hash after value from hash in hash

Is there a possibility to force the sort function to do so? :)
Sure there is! Once you realise what keys is iterating over, it becomes obvious.

The keys of your $hash are 1 and 2, so that's what $a and $b refer to in the sort block.

The final piece of the puzzle is going from there to the right value. It looks to me you want the value of "key1". That gives us:

sort { $hash->{$a}{key1} cmp $hash->{$b}{key1} } keys %$hash

Replies are listed 'Best First'.
Re^2: sort hash after value from hash in hash
by ocs (Monk) on Nov 24, 2006 at 16:39 UTC
    Thanks to your explanation I finally got it. Now I can sort everything ;)