http://qs1969.pair.com?node_id=767329


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

Hash values are often reordered when more buckets are allocated and so forth, right?

I would say the thing that makes arrays sorted is that you can say @arrayname to get the values, and they'll be in a consistent order. If you say values %hash to get the values of a hash, they will be in no particular order.

Arrays have push and pop and shift and unshift that take advantage of the order of the array. for iterates through arrays in known order; each iterates through hashes. I think not merely our usage, but the language's design, says that arrays are ordered and hashes are unordered.


Caution: Contents may have been coded under pressure.