in reply to Re: sorting array of hashes using multiple keys conditionally
in thread sorting array of hashes using multiple keys conditionally

I'm wondering why || doesn't cause a precedence problem here? I use "or" like below in this situation.

update: looked up precedence table and spaceship (<=>) and cmp have much higher priority than I thought, so I guess this is ok either way.

@a = sort { $a->{key1} <=> $b->{key1} or $a->{key2} <=> $b->{key2} } @a;

Replies are listed 'Best First'.
Re^3: sorting array of hashes using multiple keys conditionally
by jwkrahn (Abbot) on Dec 05, 2009 at 22:41 UTC
    I'm wondering why || doesn't cause a precedence problem here?

    Because the  || operator has lower precedence than the comparison operators like  <=> for example.    See perlop.