On Sun, 13 Aug 2006, Hal Fulton wrote:

> There have been numerous occasions when I wanted an
> ordered hash, but usually I can't remember to write
> them down.

I'm in the habit of automagically writing...

   hash.keys.sort

or sometimes

   hash.keys.sort_by{|k| hash[k]}.each{|k| value=hash[k]; ... }

It's just such a common idiom in my code I think I should push it into
my little collection of standard extensions to standard objects.

Why is it so common? Nobody wants a script that does very things in a
very different order depending on very small changes.

* You just spend too long explaining to people why this happens.
* Makes sporadic bugs even harder to find (it works for me, but customer is whinging)
* The results tend not to be comparable (can't diff) or repeatable.

John Carter                             Phone : (64)(3) 358 6639
Tait Electronics                        Fax   : (64)(3) 359 4632
PO Box 1645 Christchurch                Email : john.carter / tait.co.nz
New Zealand

Carter's Clarification of Murphy's Law.

"Things only ever go right so that they may go more spectacularly wrong later."

From this principle, all of life and physics may be deduced.