The shuffling algorithm of
Fisher-Yates.
Time complexity: O(N).
Time complexity: O(N).
Parameters:
| Name | Type | Description |
|---|---|---|
array |
Array | Array which should be shuffled. |
- Source:
Returns:
Shuffled array.
- Type
- Array
Example
var shuffle = require('path-to-algorithms/src/' +
'shuffle/fisheryates').shuffle;
console.log(shuffle([1, 2, 3, 4, 5])); // shuffled array