Skip to content

Instantly share code, notes, and snippets.

@pilgreen
Created March 4, 2016 15:24
Show Gist options
  • Save pilgreen/448ed963a042cd0ea88e to your computer and use it in GitHub Desktop.
Save pilgreen/448ed963a042cd0ea88e to your computer and use it in GitHub Desktop.
The Fisher-Yates shuffle.
function shuffle(array) {
var m = array.length, t, i;
while (m) {
i = Math.floor(Math.random() * m--);
t = array[m];
array[m] = array[i];
array[i] = t;
}
return array;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment