class Algorithmable::Sort::Shuffle
Public Class Methods
sort(collection)
click to toggle source
# File lib/algorithmable/sort/shuffle.rb, line 6 def self.sort(collection) return collection if collection.empty? || 2 > collection.length collection.length.times do |i| exchange(i, rand(i + 1), collection) end collection end