Skip to content

Instantly share code, notes, and snippets.

@kinopyo
Created September 30, 2012 08:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kinopyo/3806238 to your computer and use it in GitHub Desktop.
Save kinopyo/3806238 to your computer and use it in GitHub Desktop.
Javascript shuffle array.
Array.prototype.shuffle = function() {
var len = this.length;
var i = len;
while (i--) {
var p = parseInt(Math.random()*len);
var t = this[i];
this[i] = this[p];
this[p] = t;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment