in reply to Sort hash values with one key in reverse

timecatalyst,
First you need to make the flag key the first sort criteria, second ensure it is descending order not ascending, third use the spaceship operator instead of cmp because you want to treat them numerically (see perlop for details), and finally use a secondary sort by name.
@hashes = sort { $b->{flag} <=> $a->{flag} || $a->{name} cmp $b->{nam +e} } @hashes;
You may also want to consider if the Schwartzian Transform is appropriate.

Cheers - L~R

Replies are listed 'Best First'.
Re^2: Sort hash values with one key in reverse
by timecatalyst (Acolyte) on Apr 11, 2006 at 16:55 UTC
    Oh! Thanks a bunch, Limbic! My big problem was the treatment of $a and $b. I don't think I fully understood how they work up until now. That shines a lot of light on things.

    Thanks again!