On Mon, 2 Jul 2012 11:42:44 -0500
Chris Stinemetz <chrisstinem...@gmail.com> wrote:

> I have a 3 deminsional hash that I would like to sort on the value in
> descending order. I can't quite seem to figure it out
>
> The portion of the program I can't get figured out:
> ## body
> foreach my $frameNo ( keys %RNC ) {
>   foreach my $ec ( keys %{$RNC{$frameNo}} ) {

The second foreach could become:

foreach my $ec (
    sort  { $RNC{$frameNo}{$a} <=> $RNC{$frameNo}{$b} }
    keys %{ $RNC{$frameNo} }
) {
    ....
}

(If you want to swap the sort order, just swap the $a and $b round.)


(For what it's worth, I tend to use "for" instead of "foreach" as I
think it reads better, but either way will work.)



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to