Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^6: What makes an array sorted and a hash unsorted?

by herveus (Prior)
on Jun 05, 2009 at 17:21 UTC ( [id://768854]=note: print w/replies, xml ) Need Help??


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

Howdy!

You're moving the goalposts.

When you print $h{$_}, you are imposing an order by the sequence of values you assign to $_. The output sequence you are generating is not intrinsic to the hash, but extrinsic.

Your definition of %h is also flawed. You can construct a hash from a list in the manner you do, but there is no assurance that the list you get by saying (%h) will be the same as the list you used to construct the hash.

You don't get a random list when you call keys(). The ordering of the keys is unpredictable at that level. It is deterministic, in that calling keys() repeatedly will give the same list until you add or delete an element from the hash. Then it may come back with a reordered list. The hypothetical "what if perl had" or "what if perl didn't have" questions look like attempts to redefine the question to make it complicated again.

yours,
Michael
  • Comment on Re^6: What makes an array sorted and a hash unsorted?

Replies are listed 'Best First'.
Re^7: What makes an array sorted and a hash unsorted?
by jethro (Monsignor) on Jun 06, 2009 at 01:26 UTC

    You're moving the goalposts

    Yes, and I'm offering flawed arguments, because ultimately we know that hashes are not ordered. Very much a senseless discussion by now. Still hoping to get the last word ;-).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-25 10:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found