Skip to content

Instantly share code, notes, and snippets.

@usagi
Created July 19, 2012 23:13
Show Gist options
  • Select an option

  • Save usagi/3147544 to your computer and use it in GitHub Desktop.

Select an option

Save usagi/3147544 to your computer and use it in GitHub Desktop.
Array.prototype.shuffle; ref: http://la.ma.la/blog/diary_200608300350.htm
Array.prototype.shuffle = function() {
var i = this.length;
while(i){
var j = Math.floor(Math.random()*i);
var t = this[--i];
this[i] = this[j];
this[j] = t;
}
return this;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment