stupid simple array shuffle in ruby


/ Published in: Ruby
Save to your folder(s)



Copy this code and paste it in your HTML
  1. class Array
  2. def shuffle
  3. sort_by { rand }
  4. end
  5.  
  6. def shuffle!
  7. self.replace shuffle
  8. end
  9. end

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.