/**
* Randomize array element order in-place.
* Using Durstenfeld shuffle algorithm.
* @memberof module:util
*/
const shuffle = (array) => {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
const temp = array[i];
// eslint-disable-next-line no-param-reassign
array[i] = array[j];
// eslint-disable-next-line no-param-reassign
array[j] = temp;
}
};
module.exports = shuffle;
Source