Skip to content

shuffle

Randomly shuffle an array

197 bytes

Usage

Create a new array with the items of the given array but in a random order. The randomization is done using the Fisher-Yates algorithm, which is mathematically proven to be unbiased (i.e. all permutations are equally likely).

import * as _ from 'radashi'
const fish = [
{
name: 'Marlin',
weight: 105,
source: 'ocean',
},
{
name: 'Salmon',
weight: 22,
source: 'river',
},
{
name: 'Salmon',
weight: 22,
source: 'river',
},
]
_.shuffle(fish)