From: "Dan Stevens (IAmAI)" Date: 2006-12-31T00:32:25+09:00 Subject: Re: Randomizing an Array? I found a library called 'rand.rb': http://raa.ruby-lang.org/project/rand/. It allows you to select an element at random from an array and 'scramble' (randomize the order) of them as well. Description: Helper methods for Enumerable, Array, Hash, and String that let you pick a random item or shuffle the order of items. Examples with Array: [1,2,3,4].pick # => 2 (pick random element) [1,2,3,4].shuffle # => [2, 4, 1, 3] (return random-sorted version) a = [1,2,3,4] a.pick! # => 3 a # => [1,2,4] (remove the picked element) On 29/12/06, Daniel Waite wrote: > Sorry, I guess a use-case would be helpful. > > Call #randomize or #randomize! on any array to mix up its elements. > > [ 5, 10, 15, 20, 25 ].randomize # [25, 15, 5, 20, 10] > > > -- > Posted via http://www.ruby-forum.com/. > >