How to randomly sort (scramble) an array in Ruby?

Viewed 78434

I'd like to have my array items scrambled. Something like this:

[1,2,3,4].scramble => [2,1,3,4]
[1,2,3,4].scramble => [3,1,2,4]
[1,2,3,4].scramble => [4,2,3,1]

and so on, randomly

5 Answers
Related