Skip to content

Instantly share code, notes, and snippets.

@zakhardage
Last active August 29, 2015 14:22
Show Gist options
  • Select an option

  • Save zakhardage/530639783f95844b790a to your computer and use it in GitHub Desktop.

Select an option

Save zakhardage/530639783f95844b790a to your computer and use it in GitHub Desktop.
Fisher Yates
function fisherYates ( myArray ) {
var i = myArray.length,j,temp;
if (i === 0) return false;
while (--i) {
j = Math.floor(Math.random()*(i+1));
temp = myArray[i];
myArray[i] = myArray[j];
myArray[j] = temp;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment