From: Dan Zwell Date: 2007-08-28T02:28:25+09:00 Subject: Re: sort_by { rand } not working thomas.macklin@gmail.com wrote: > If you don't mind removing duplicates, Sets are non-ordered, so you > could do > s = Set.new > @all.each do |e| s.add(e) end > > That will be non-ordered, but duplicates will get stripped. > > Tom > > > Non-ordered isn't the same as randomized. Sets most certainly are ordered, we (the non-ruby-core-developers) just don't know how. The point is that they aren't guaranteed to be random. Try running the above code and see--it results in the same ordering each time, regardless of the order in which the elements are added. For some data sets, it will probably appear more random than others. Dan