Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Mysterious hash behaviour

by borisz (Canon)
on Apr 07, 2005 at 07:01 UTC ( [id://445557]=note: print w/replies, xml ) Need Help??


in reply to Mysterious hash behaviour

Hashes are unordered. If you want the keys ordered, use sort keys %sortListArr. Another solution is to use Tie::IxHash, Tie::IxHash::Easy or Tie::DxHash.
Boris

Replies are listed 'Best First'.
Re^2: Mysterious hash behaviour
by tsam (Novice) on Apr 07, 2005 at 07:06 UTC
    sort keys %sortListArr works pretty good. Thanx:)
Re^2: Mysterious hash behaviour
by Limbic~Region (Chancellor) on Apr 07, 2005 at 13:26 UTC
    borisz,
    I agree with you but feel you have left out some information that may result in misunderstandings. Insert order (which the modules you listed are good at) is often not the same as a desired sorted order. That is why I created Tie::Hash::Sorted. In this particular case, Tie::IxHash also can do naive sorts that meet the stated requirements but fail if gets any more complicated.

    Cheers - L~R

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://445557]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-03-29 01:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found