Skip to content

Instantly share code, notes, and snippets.

@appden
Forked from kamicane/Array.Shuffle.js
Created June 20, 2009 23:37
Show Gist options
  • Save appden/133332 to your computer and use it in GitHub Desktop.
Save appden/133332 to your computer and use it in GitHub Desktop.
// Array shuffle for MooTools
Array.implement({
// don't remember where I saw this one-liner first...
shuffle: function(){
for (var j, x, i = this.length; i; j = Math.floor(Math.random() * i), x = this[--i], this[i] = this[j], this[j] = x);
return this;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment