Skip to content

Instantly share code, notes, and snippets.

@photonstorm
Created April 3, 2013 11:49
Show Gist options
  • Save photonstorm/5300530 to your computer and use it in GitHub Desktop.
Save photonstorm/5300530 to your computer and use it in GitHub Desktop.
array shuffle
function shuffleArray(array) {
for (var i = array.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var temp = array[i];
array[i] = array[j];
array[j] = temp;
}
return array;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment