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}; ... }
In reply to Re: Sort of anonymous hash
by ikegami
in thread Sort of anonymous hash
by larsss31
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |