in reply to sort mechanism
I think the sort function you provided is only doing what you want by coincidence. When you say:
sort { ($a) <=> ($b) } keys %hash
The ()'s around $a and $b force the <=> operator to use list context. If we know that $a and $b will always be single (numeric) elements (as in this case), this will produce the correct behavior - but if they were lists, things would be different.
In list context, I believe <=> compares the two lists element by element - damn if I can find where that's documented, though. Brother monks? Anybody got a pointer?.
Disclaimer: Again, this is trivia, won't affect the code shown, and I need more coffee.
Peace,
-McD
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: sort mechanism
by extremely (Priest) on Apr 06, 2001 at 23:17 UTC | |
by McD (Chaplain) on Apr 06, 2001 at 23:32 UTC | |
by extremely (Priest) on Apr 07, 2001 at 00:01 UTC | |
by McD (Chaplain) on Apr 07, 2001 at 00:36 UTC | |
by extremely (Priest) on Apr 07, 2001 at 00:52 UTC |