shuffle/richarddurstenfeld

Shuffle of an array elements. This algorithm is modified version of Fisher-Yates shuffle algorithm and is introduced by Richard Durstenfeld.

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