From: "ara.t.howard" Date: 2008-09-19T01:13:44+09:00 Subject: Re: Preserve insert order in a Hash On Sep 18, 2008, at 10:01 AM, jim finucane wrote: > If scale is needed this has been implemented by Takuma Ozawa as a very > efficient RB tree which I used on a Mac: > > sudo gem install rbtree > irb > require 'rbtree' > a=RBTree.new > a['x']=1 > a['z']=2 > a['y']=3 > a cfp:~ > cat a.rb require 'rubygems' require 'rbtree' # rbtree is sorted by the keys 'natural' sort order # *not* the insertion order rb = RBTree.new rb['z'] = 3 rb['y'] = 2 rb['x'] = 1 rb.each do |key, value| puts "#{ key } : #{ value }" end cfp:~ > ruby a.rb x : 1 y : 2 z : 3 a @ http://codeforpeople.com/ -- we can deny everything, except that we have the possibility of being better. simply reflect on that. h.h. the 14th dalai lama