From: "Jan E." Date: 2012-06-18T21:19:24+09:00 Subject: Re: Overwriting one Ruby array of arrays with another Craig Law wrote in post #1064944: > ... and it produces an array in the order that I want it but it only > contains the keys (i.e. [1,1]). How do I include the ["X","20120617"] so > that I get [1, 1, "X", "20120617"] in the array? I just can't figure out > how to tack on the values associated with the keys. Well, you've already done this with Martin's approach. The only difference is that "sort" has a block now, so you should probably do the key sorting and the mapping separately: #------------------------------ sorted_keys = hash1.keys.sort do |(x1, y1), (x2, y2)| y_comparison = y2 <=> y1 if y_comparison != 0 y_comparison else x1 <=> x2 end end result = sorted_keys.map {|key| key + hash1[key]} #------------------------------ But I agree with Robert that you should use specific objects instead of hashes. The problem with your hashes is that their structure is neither documented (unless you write a comment) nor enforced. You may accidently put wrong values into the hashes and won't even notice. -- Posted via http://www.ruby-forum.com/.