http://www.perlmonks.org?node_id=585884

ocs has asked for the wisdom of the Perl Monks concerning the following question:

Hi. I have a hash going like this:
$hash = { 1 => { key1 => string1, key2 => string2 }, 2 => { key1 => string3, key2 => string4 } }
I want to sort this thing after string1. I tried this one:
foreach my $key (sort { $hash->{'key1'} {$a} cmp $hash->{'key1'} {$b} +} keys %$hash) { ... }
I doesn't work :(
Is there a possibility to force the sort function to do so? :)
Thanx for any help!