in reply to Sort of anonymous hash

for my $d (sort {$a cmp $b} keys %{{map {$_ => $hash{$_}{desc}} keys % +hash}} ) { ... ... }
is unreadable. It should be
my %descs = map { $_ => $hash{$_}{desc} } keys %hash; for my $d ( sort keys %descs ) { ... ... }
The answer to your answer is now obvious.
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??

my %descs = map { $_ => $hash{$_}{desc} } keys %hash; for my $d ( sort { $descs{$a} cmp $descs{$b} } keys %descs ) { my $desc = $descs{$d}; ... }
can be written as
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
    if i wanted to use

    my %descs = map { $_ => $hash{$_}{desc} } keys %hash; for my $d ( sort keys %descs ) { ... ... }

    i had written that.
    The question was about not using an explicit intermediate hash.
    Thanks anyway for your contribute