# Module: shuffle

Shuffles an array, i.e. returns a new array with same elements in a random order.

import { shuffle } from 'utilist';

shuffle([1, 2, 3, 4, 5]); // returns [2, 4, 1, 5, 3] (for example)

remarks

  • This method uses a version of the Fisher-Yates shuffle.
  • This method does not mutate the array passed, but returns a new array instead.

# Functions

# shuffle

shuffleT›(elements: T[]): T[]

Defined in src/shuffle.ts:23

Type parameters:

T

Parameters:

Name Type Description
elements T[] The array to be shuffled.

Returns: T[]