From: Phillip Hutchings Date: 2006-08-21T11:04:55+09:00 Subject: Re: Why Does Hash Apparently Reorder Its Internal Representation And Other Associated Ponderings On 8/21/06, thoran @ thoran. com wrote: > I was surprised to find the following... Really? Take a comsci course at uni > I realise that it is a hash and that access is expected to be by key, > but sometimes retaining the presented order may be desired. And > anyway, why reorder it at all? It's not 'reordered', it's stored in a hash table. Think of how MD5 represents a unique key for almost every possible value, but the hash has no real connection to the original value. A hash table is stored using similar keys, though you are allowed duplicate keys for a hash table, and if you go in to the mathematical theory of it there is a lot of speed gained this way especially if you're using large keys, such as in i18n applications where each string is stored in a hash table. That's why it's called a hash and not an array. -- Phillip Hutchings http://www.sitharus.com/