You aren't creating a sorted hash. There is no such thing as a sorted hash (well, unless you use something like Tie::IxHash).
Hashes are by nature unordered. All you are doing here is adding keys to a hash. You're adding them in the correct order, but they are stored in a (seemingly) random order.
If you want things stored in a fixed order, then use an array. Not a hash.
See the Copyright notice on my home node.
"The first rule of Perl club is you do not talk about Perl club." -- Chip Salzenberg
In reply to Re: problem while sorting hash
by davorg
in thread problem while sorting hash
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |