shuffle-matrix
Version:
Fisher-Yates for shuffle array and matrix
43 lines (33 loc) • 839 B
Markdown
[](https://www.npmjs.com/package/shuffle-matrix)
A JavaScript implementation of the Fisher-Yates Shuffle algorithm for array and matrix.
* Node.js 6+
`npm install shuffle-matrix --save`
```js
let shuffle = require('shuffle-matrix');
let origin = [1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9];
let result = shuffle(origin);
```
```js
let randomFunc = function() {
return 0.618
};
let shuffle = require('shuffle-matrix');
let origin = ['a', 'b', 'c', 'd', 'e', 'f'];
let result = shuffle(origin, randomFunc);
```
```js
let shuffle = require('shuffle-matrix');
let origin = [
[],
2,
[],
[],
11,
[]
];
let result = shuffle(origin);
```