Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

array-shuffle

sindresorhus104.3kMIT3.0.0TypeScript support: included

Randomize the order of items in an array

array, list, shuffle, sort, random, rand, fisher, yates, durstenfeld

readme

array-shuffle

Randomize the order of items in an array

Uses the Durstenfeld algorithm which is based on the Fisher–Yates algorithm.

Install

$ npm install array-shuffle

Usage

import arrayShuffle from 'array-shuffle';

const shuffled = arrayShuffle([1, 2, 3, 4, 5, 6]);
//=> [3, 5, 4, 1, 2, 6]

API

arrayShuffle(array)

array

Type: Array

The array to shuffle.