From: Farrel Lifson Date: 2006-11-23T14:38:29+09:00 Subject: Re: Compare Array Values? On 23/11/06, Darshan.Ishaya wrote: > Well, I'm new to Ruby, but it was an interesting question so I gave it > a stab. My first idea was > > a.sort == b.sort > > which works if all the elements of an array of of the same class. But > if you mix objects of different class (like you example with Fixnums > and a String), sort() craps out on it. You can pass a block to sort, > but I couldn't think of a good way to use that to our advantage. So I > resorted to more of a brute force method: Would this work? a.sort_by{|n| n.hash} == b.sort_by {|n|n.hash} Farrel