in reply to sorting hashes by value

You got lots of replies already, one more comment is that, you can either sort the entities as numbers or characters. the order would be different, for example, if you have a list:
@a = (2, 10, 1); sort {$a <=> $b} @a would give you (1, 2, 10), when sort {$a cmp $b} @a will give you (1, 10, 2)
the second one is the default.

Replies are listed 'Best First'.
Re: Re: sorting hashes by value
by pg (Canon) on Nov 10, 2002 at 01:35 UTC
    Another basic thing about sort you might want to know is that, you can determining the sroting order simply by the oder of $a and $b. If you have
    @a = (1,3,2); sort {$a <=> $b} gives you (1,2,3), when sort {$b <=> $a} gives you (3,2,1)