Skip to content

shuffle

ts
function Array.shuffle<T>(target: readonly T[]): T[]

Returns a new array with the elements of array randomly shuffled.

Example

ts
import { Array } from "@monstermann/array";

Array.shuffle([1, 2, 3, 4]); // [3, 1, 4, 2] (random)
ts
import { Array } from "@monstermann/array";

pipe([1, 2, 3, 4], Array.shuffle()); // [3, 1, 4, 2] (random)