From: Rick DeNatale Date: 2007-10-26T02:03:17+09:00 Subject: Re: Array of Pairs data structure? On 10/25/07, Greg Willits wrote: > OK, nevermind, I think I found enough functionality to get me by. > > An array of arrays is sortable (an array of hashes is not). > > And, array.assoc provides a lookup of a specific "pair" > > y = [['bbb','beta'], ['ggg','gamma'], ['aaa','alpha']] > > puts y.assoc('ggg') # will return ['ggg', 'gamma] > > puts y.sort # actually works. Weeee. You might also consider using a hash, for access and produce the array when needed to sort. Consider: h = {"color" => "red", "shape" => "trapezoid", "size" => "small" } h.to_a # => [["size", "small"], ["shape", "trapezoid"], ["color", "red"]] h.to_a.sort # => [["color", "red"], ["shape", "trapezoid"], ["size", "small"]] -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/