Skip to content

Instantly share code, notes, and snippets.

@duncanbeevers
Created July 20, 2010 00:10
Show Gist options
  • Save duncanbeevers/482247 to your computer and use it in GitHub Desktop.
Save duncanbeevers/482247 to your computer and use it in GitHub Desktop.
Fisher-Yates shuffle
Array.prototype.shuffle = function() {
var i = this.length, k, e;
while (--i) {
k = Math.floor(Math.random() * i);
if (k != i) {
e = this[i];
this[i] = this[k];
this[k] = e;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment