http://qs321.pair.com?node_id=767315

It always bothers me when someone says hash are unsorted.

An array is sorted because it can return its values in order of ascending keys (indexes). But a hash can do the same thing. In fact, hashes can do everything an array can do with no extra state information. (It's just more expensive.)

That means that hashes are just as sorted as arrays in theory.

The difference is how they are used in practice. Array keys (indexes) only convey order, while hash keys are part of the true value of the hash element. Therefore, array values can be reordered, but hash values can't be reordered.

That hashes are unsorted isn't a property of hashes so much as of the way we use them.

</ramblings>