From: Jim Crigler Date: 2004-12-03T06:07:43+09:00 Subject: Re: ordered hash ? Something like this (hoping GG doesn't mess up the indenting): # Assumes you're not initializing with values at the beginning, i.e. # h = InsertOrderHash.new # Extension to the general case is left as an exercise for the reader # (I've always wanted to say that ;-) class InsertOrderHash < Hash def initialize(*args) @insert_order = Array.new end def []=(key, val) @insert_order.push key unless self.key? key super end def each # Assumes block follows @insert_order.each do |key| yield key, self[key] end end