Skip to content

shuffleInPlace

shuffleInPlace(x, randomSource?): any[]

Defined in: src/shuffle_in_place.js:18

A Fisher-Yates shuffle in-place - which means that it will change the order of the original array by reference.

This is an algorithm that generates a random permutation of a set.

any[]

sample of one or more numbers

Function

an optional entropy source that returns numbers between 0 inclusive and 1 exclusive: the range [0, 1)

any[]

x

var x = [1, 2, 3, 4];
shuffleInPlace(x);
// x is shuffled to a value like [2, 1, 4, 3]