From: Hal Fulton Date: 2004-03-04T08:07:15+09:00 Subject: Re: why are Hashes so unsorted? what's your solution? John W. Kennedy wrote: > David Garamond wrote: > >> Most language don't guarantee insert order for hash, in fact IIRC some >> deliberately randomize it. > > > They /all/ do, or else they're calling something a "hash" that ain't. > > They're /called/ "hashes" (and have been since the days of vacuum-tube > mainframes) /because/ the process "makes a hash of" the ordering. You're correct, of course, as is Lothar. The reason for the new (mis)use of the term, I believe, is this. The language feature is named for its implementation (an unfortunate historical quirk). I am more interested in its interface. Ideally the language feature should have a name that reflects how it can be used rather than how it is implemented. I'm as guilty as anyone else of saying "ordered hash." When I say it, I mean a data structure whose elements can be addressed like an array, but with a non-numeric key which is an arbitrary object. Those are interface issues. I care about how I put things in and how I get them out. I don't want to know how it's implemented (except that the implementation "pokes through" when I retrieve the list and it's not in the original order). This reminds me a little of the people who say you can't talk about the "screen" of a laptop. It's a "display"; there's no network of wires crisscrossing in it, and hence no "screen." The term "hash" is so much more fun and elegant than "associative array." Let's come up with a term that is both elegant and accurate for an ordered entity with a hash-like interface. Hal