From: Raf Coremans Date: 2007-08-26T22:37:30+09:00 Subject: Re: sort_by { rand } not working ------=_Part_30912_10263209.1188135449011 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline 2007/8/26, Mike Dershowitz : > > Hello: > > I've got an array of arrays that I'd like to sort_by random. each > individual array is just a hash of a value and then an object. Is there > some reason why sort_by { rand } wouldn't work? My code is simple (teams > is populated with a db call): > > @teams.each do |t| > @all << ["t",t] > end > #current not working > @all.sort_by { rand } > > Any ideas? Am I stretching the limit of the rand function? > > Thanks! > > Mike > -- > Posted via http://www.ruby-forum.com/. > > Hi, @all.sort_by { rand } returns a randomly sorted array, but leaves @all intact. Perhaps you wanted @all = @all.sort_by { rand }? Regards, R. ------=_Part_30912_10263209.1188135449011--