Not true. Of course you can sort a hash. The random part is the order in which the keys get inserted, but if you do
you'll get the keys in alphabetical order. If you dosort(keys %hash)
you'll get the keys in numerical order.sort { $a <=> $b } keys %hash;
The only thing you can't get from the hash is the order in which things were added
Update: I can't type ... switched can get to can't get in the sentence above, sort of changes the meaning :)
Update: sauoq is correct and I'm completely wrong (not the first time) I wasn't thinking about the fact that sort is simply returning the keys in the order which you ask. The original remains the same. Apologies sweetblood.
Lobster Aliens Are attacking the world!In reply to Re: Re: sorting an array of hashes by the value of the keys
by cfreak
in thread sorting an array of hashes by the value of the keys
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |