From: sto.mar@... Date: 2013-03-14T01:02:29+09:00 Subject: Re: question on watir Am 13.03.2013 12:59, schrieb Raj pal: > Thank you very much this would help me, > > and I have another question, > > consider the below hash, > > a={1=>2,3=>4,5=>6} > > when I try to print the key values, it is not printing in the order > > a.each do |key,value| > puts key > end > > it's printing 5 3 1 then you are using a very old Ruby version. > > Is there any way could I able to print in order.? 1. In case you need insertion order: - upgrade to 1.9.3 or 2.0.0 (nowadays hashes keep the insertion order) - use an array 2. In case you need sorting order: sort before printing 1.8.7 :005 > a.sort.each do |key,value| 1.8.7 :006 > puts key 1.8.7 :007?> end 1 3 5 > > RAJ > --