Posted By

inkdeep on 03/10/10


Tagged

sort random array ruby


Versions (?)

stupid simple array shuffle in ruby


 / Published in: Ruby
 

  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  

You need to login to post a comment.