randomizing an array in ruby (the right way)
# be sure to use sort_by rather than sort quiz = (1..10).to_a quiz.sort_by { rand }
DZone Snippets > sikelianos > random
12388 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
# be sure to use sort_by rather than sort quiz = (1..10).to_a quiz.sort_by { rand }