Skip to content

Instantly share code, notes, and snippets.

@findzen
Created December 7, 2011 21:52
Show Gist options
  • Save findzen/1444860 to your computer and use it in GitHub Desktop.
Save findzen/1444860 to your computer and use it in GitHub Desktop.
Array shuffle
Array.shuffle = function(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