Skip to content

Instantly share code, notes, and snippets.

@tlxue
Created April 13, 2012 07:21
Show Gist options
  • Save tlxue/2374779 to your computer and use it in GitHub Desktop.
Save tlxue/2374779 to your computer and use it in GitHub Desktop.
ArrayRandomShuffle
function shuffle(array) {
var tmp, current, top = array.length;
if(top) while(--top) {
current = Math.floor(Math.random() * (top + 1));
tmp = array[current];
array[current] = array[top];
array[top] = tmp;
}
return array;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment