in reply to Sort of anonymous hash
is unreadable. It should befor my $d (sort {$a cmp $b} keys %{{map {$_ => $hash{$_}{desc}} keys % +hash}} ) { ... ... }
The answer to your answer is now obvious.my %descs = map { $_ => $hash{$_}{desc} } keys %hash; for my $d ( sort keys %descs ) { ... ... }
my %descs = map { $_ => $hash{$_}{desc} } keys %hash; for my $d ( sort { $descs{$a} cmp $descs{$b} } keys %desc ) { ... ... }
Update: On the other hand, why are you building a hash at all??
can be written asmy %descs = map { $_ => $hash{$_}{desc} } keys %hash; for my $d ( sort { $descs{$a} cmp $descs{$b} } keys %descs ) { my $desc = $descs{$d}; ... }
for my $d ( sort { $hash{$a}{desc} cmp $hash{$b}{desc} } keys %hash ) +{ my $desc = $hash{desc}{$d}; ... }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Sort of anonymous hash
by larsss31 (Acolyte) on Sep 30, 2009 at 08:07 UTC |