Module: Suture::Util::Shuffle
- Defined in:
- lib/suture/util/shuffle.rb
Class Method Summary collapse
Class Method Details
.shuffle(random, unshuffled_array) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/suture/util/shuffle.rb', line 3 def self.shuffle(random, unshuffled_array) old_array = unshuffled_array.dup new_array = [] while new_array.size < unshuffled_array.size index = random.rand(old_array.size) new_array << old_array.delete_at(index) end return new_array end |