fisher-yates

A compact module to randomly sort an Array

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
fisher-yates
501.0.37 years ago8 years agoMinified + gzip package size for fisher-yates in KB

Readme

fisher-yates
TRAVIS NPM
A compact module to randomly sort an Array.

Example

var shuffle = require('fisher-yates')

console.log(shuffle([1, 2, 3]))
// => [3, 1, 2]

// supports custom rng returning [0, 1)
console.log(shuffle([1, 2, 3], Math.random))
// => [2, 3, 1]

To shuffle in-place:
var shuffleInplace = require('fisher-yates/inplace')
var array = [1, 2, 3]

shuffleInplace(array)
console.log(array)
// => [2, 1, 3]

LICENSE MIT