lib/garcon/core_ext/random.rb
# As with #shuffle but modifies the array in place.
# The algorithm used here is known as a Fisher-Yates shuffle.
#
# @example
#   a = [1,2,3,4]
#   a.shuffle!
#   a  # => [2,4,1,3]
#
As with #shuffle but modifies the array in place.
The algorithm used here is known as a Fisher-Yates shuffle.
As with #shuffle but modifies the array in place . The algorithm used here is known as a Fisher - Yates shuffle .
def shuffle!
      s = size
      each_index do |j|
        i = SecureRandom.random_number(s-j)
        tmp = self[j]
        self[j] = self[j+i]
        self[j+i] = tmp
      end
      self
    end
def shuffle! s = size each_index do | j | i = SecureRandom . random_number ( s - j ) tmp = self [ j ] self [ j ] = self [ j + i ] self [ j + i ] = tmp end self end
As with #shuffle but modifies the array in place.
As with #shuffle but modifies the array in place .
example
None