[prev in list] [next in list] [prev in thread] [next in thread]
List: ruby-talk
Subject: [ruby-talk:28230] Re: Hash.keys Q
From: "Jason Voegele" <jason () jvoegele ! com>
Date: 2001-12-11 15:28:48
[Download RAW message or body]
[snip]
>> Now options.keys returns ["Password", "Host", "Port", "Name"]
>>
>> I would expect ["Host", "Port", "Name", "Password"]
>>
>> is there an explanation for this ?
>
> Yes: the order of hash keys is not guaranteed. I *think* #keys
> returns the keys in the same order when called multiple times, but I'm
> not 100% sure. In any case, that order itself cannot be predicted.
>
> I believe various people have written various OrderedHash
> extensions... (very helpful advice, I know :-) You could search on
> <http://www.ruby-talk.org> to see if there's been discussion here.
Theres one at http://sourceforge.net/projects/rubycollections/
Look for rubycollections/rbc/sorted_hash.rb under CVS.
Jason Voegele
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic