Node.js examples for Array:Shuffle
Use Random function to shuffle array
Array.prototype.shuffle = function () { var tmp, current, top = this.length; if (top) while(--top) { current = Math.floor(Math.random() * (top + 1)); tmp = this[current];//w ww . j a v a 2 s . com this[current] = this[top]; this[top] = tmp; } return this; };