Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: What makes an array sorted and a hash unsorted? (fleas)

by tye (Sage)
on Jun 07, 2009 at 08:43 UTC ( [id://769244]=note: print w/replies, xml ) Need Help??


in reply to Re: What makes an array sorted and a hash unsorted?
in thread What makes an array sorted and a hash unsorted?

A hash could be defined as an ordered list of key/value pairs.

I'll amplify your objections to your own offered premise. Since inserting a new key into a hash can significantly change the "order" of the previously inserted keys, I disagree that a Perl hash can be reasonably characterized as "an ordered list of key/value pairs". Certainly, at any given moment, the key/value pairs in an ordinary Perl hash have a defined order. And that particular order is quite useless, incidental, out of our control, and even inconstant. An "ordered" data structure mustn't shuffle its contents simply because a new item is being inserted. It is impossible to store items in computer memory and not have those items in some "order". That doesn't make every data structure into an "ordered data structure".

Since it is possible for %one= %two to leave %one with its keys in a different order than %two's, a Perl hash isn't "an ordered list of key/value pairs". Copying a hash doesn't (always) copy the order because the order is only an incidental part of the data structure.

- tye        

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2024-04-18 07:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found