On Thu, Sep 18, 2008 at 11:13 AM, Me Me <emanuelef / tiscali.it> wrote:
> Thomas B. wrote:
>> Pe=F1a, Botp wrote:
>>> From: Me Me [mailto:emanuelef / tiscali.it]
>>> # I would like to know if it's possible to insert values in a Hash and
>>> # then extract all of them in the same insertion order.
>>>
>>> only in ruby 1.9
>>
>> Could anybody explain why this feature was added? Isn't it going to slow
>> down the operations on the Hash? I think it is useless to mix Array with
>> Hash.
>>
>> TPR.
>
> well, basically I just need a Hash to use String as indexes like
>
> sourceInfo =3D Hash.new
> sourceInfo["var1"]=3D123
> sourceInfo["var2"]=3D2
> sourceInfo["var3"]=3D3
> sourceInfo["var4"]=3D23
>
> and then print them in the exact order of insertion

Can't you just sort them on the way out?
i.e.

sourceinfo.keys.sort.each { |k|
  sourceinfo[k].do_stuff
}
--=20
Rasputnik :: Jack of All Trades - Master of Nuns
http://number9.hellooperator.net/