function shuffle
shuffle<T>(items: T[]): void

Performs an in-place shuffle of an array in linear time.

This function uses the Fisher-Yates (also known as Knuth) shuffle algorithm to rearrange the elements in the array in a random order. The shuffle is performed in-place, meaning that it modifies the original array instead of creating a new one. The time complexity of the algorithm is O(n), where n is the number of elements in the array.

Type Parameters

Parameters

items: T[]

Return Type

void

Usage

import { shuffle } from ".";