Re: sorting by rand?



Marcin Raczkowski wrote:
On Monday 30 April 2007 02:55, Dan Zwell wrote:
l = a.length
a.each_index { |x| a[x] = a[rand(l)] }


a.each_index { |x| r= rand(l); a[x], a[r] = a[r], a[x] }


I forgot you could do that. No wonder arrays don't have a swap method!

.