From: Ilan Berci Date: 2007-01-03T01:36:53+09:00 Subject: Re: Randomizing an Array? jwcooper wrote: > I'm trying to randomize an array, and this is what I have: > > arr_set_unordered = randomizer(arr_set) > > def randomizer(arr) > result = arr.collect { arr.slice!(rand arr.length) } > end > > It does randomize it, but it only returns 3 values instead of the 5 > values that I'm expecting. Any ideas why? > > Thank you! ilans-Mac:~ ilan$ irb irb(main):001:0> (1..10).to_a.sort {rand} => [10, 6, 1, 7, 3, 8, 5, 9, 4, 2] irb(main):002:0> -- Posted via http://www.ruby-forum.com/.