shuffle
shuffle(
x,randomSource?):any[]
Defined in: src/shuffle.js:17
A Fisher-Yates shuffle
is a fast way to create a random permutation of a finite set. This is
a function around shuffle_in_place that adds the guarantee that
it will not modify its input.
Parameters
Section titled “Parameters”any[]
sample of 0 or more numbers
randomSource?
Section titled “randomSource?”Function
an optional entropy source that returns numbers between 0 inclusive and 1 exclusive: the range [0, 1)
Returns
Section titled “Returns”any[]
shuffled version of input
Example
Section titled “Example”var shuffled = shuffle([1, 2, 3, 4]);shuffled; // = [2, 3, 1, 4] or any other random permutation