gabriele renzi <surrender_it / rc1.vip.ukl.yahoo.com> writes:

> il Mon, 12 Jul 2004 07:55:58 +0900, Mikael Brockman
> <phubuh / phubuh.org> ha scritto::
>
>>
>>Here's some shuffling stuff:
>>
>>| class Array
>>|   def shuffle!
>>|     each_index do |j|
>>|       i = rand(size - j)
>>|       self[j], self[j+i] = self[j+i], self[j]
>>|     end
>>|     self
>>|   end
>>|   
>>|   def shuffle
>>|     self.clone.shuffle!
>>|   end
>>| end 
>>
>>And that's it.
>
> the best shuffle I can think of is the Grossian shuffle (quoting
> Flroain Gross (actually written with a different character than ss):
>
> class Array
>  def shuffle
>   sort_by {rand}
>  end
> end
>
> You may even found extensions.rubyforge.org interesting

It's very nifty indeed.  I heard it was biased in some obscure way,
though.

  mikael