
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
array-shuffle
Advanced tools
Randomize the order of items in an array
Uses the Durstenfeld algorithm which is based on the Fisher–Yates algorithm.
npm install array-shuffle
import {arrayToShuffled, arrayShuffle} from 'array-shuffle';
// Create a new shuffled array
const shuffled = arrayToShuffled([1, 2, 3, 4, 5, 6]);
//=> [3, 5, 4, 1, 2, 6]
// Shuffle in-place
const array = [1, 2, 3, 4, 5, 6];
arrayShuffle(array);
console.log(array);
//=> [3, 5, 4, 1, 2, 6]
Create a new array with the items randomized (does not mutate the original array).
Returns a new array with the items randomized.
Type: Array
The array to shuffle.
Type: object
Type: () => number
Custom random number generator that returns a float between 0 (inclusive) and 1 (exclusive). This is useful for deterministic shuffling when you use a seeded generator.
import {arrayToShuffled} from 'array-shuffle';
const randomNumberGenerator = () => 0;
const deterministic = arrayToShuffled([1, 2, 3, 4, 5, 6], {randomNumberGenerator});
//=> [2, 3, 4, 5, 6, 1]
Randomize the order of items in an array, mutating the array in-place.
Returns the input array shuffled.
Type: Array
The array to shuffle.
Type: object
Type: () => number
Custom random number generator that returns a float between 0 (inclusive) and 1 (exclusive). This is useful for deterministic shuffling when you use a seeded generator.
FAQs
Randomize the order of items in an array
The npm package array-shuffle receives a total of 77,311 weekly downloads. As such, array-shuffle popularity was classified as popular.
We found that array-shuffle demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.