Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I have this snippet that try to get the sorted keys.my $HoH = { 'pk1' => { 'sk1' => 'val1', 'sk2' => 'val2, 'score'=> 47 }, 'pk2' => { 'sk1' => 'val3', 'sk2' => 'val4', 'score' => 14 }, 'pk3' => { 'sk1' => 'val5', 'sk2' => 'val6', 'score' => 64 } };
Supposedly it returns: pk3,pk1,pk2 as result. But it fails. Many thanks for your time.my @best_key = sort { keys %{$HoH{'score'}{$a}} <=> keys %{$HoH{'score +'}{$b}} } keys %HoH;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sorting HoH
by Hena (Friar) on May 25, 2005 at 07:29 UTC | |
|
Re: Sorting HoH
by holli (Abbot) on May 25, 2005 at 07:33 UTC | |
by Jasper (Chaplain) on May 25, 2005 at 12:14 UTC | |
|
Re: Sorting HoH
by Fang (Pilgrim) on May 25, 2005 at 07:34 UTC | |
|
Re: Sorting HoH
by thcsoft (Monk) on May 25, 2005 at 08:48 UTC |