ruby - Check if two arrays have the same contents (in any order) -


i'm using ruby 1.8.6 rails 1.2.3, , need determine whether 2 arrays have same elements, regardless of whether or not they're in same order. 1 of arrays guaranteed not contain duplicates (the other might, in case answer no).

my first thought was

require 'set' a.to_set == b.to_set 

but wondering if there more efficient or idiomatic way of doing it.

this doesn't require conversion set:

a.sort == b.sort 

Comments

Popular posts from this blog

How do you change vbulletin's home page to the forums instead of the default (CMS or Activity Stream)? -

c++ - Troubles when compiling phash program -