From: Patrick Doyle Date: 2008-10-02T03:11:33+09:00 Subject: Re: Ordered hash hack for < ruby 1.9? ------=_Part_61997_6767513.1222884763416 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Why not iterate over myhash.keys.sort instead of just myhash.keys? --wpd On Wed, Oct 1, 2008 at 2:00 PM, Ben Johnson wrote: > I am having an issue testing my code because hashes don't have a > consistent order when you iterate over them. For example, one of the > methods that I am trying to test iterates over a hash and creates a > string. That string is in a different order every time, and my tests > keep failing. > > What would be perfect is if I could modify how the Hash class works so > it preserves the insert order, but only when I am testing. So I could > include this file in my tests. > > Is there anything out there that does this? Thanks for your help. > -- > Posted via http://www.ruby-forum.com/. > > ------=_Part_61997_6767513.1222884763416--