Skip to content

Instantly share code, notes, and snippets.

@mistadikay
Created March 25, 2015 08:16
Show Gist options
  • Save mistadikay/578275bf226aad291520 to your computer and use it in GitHub Desktop.
Save mistadikay/578275bf226aad291520 to your computer and use it in GitHub Desktop.
shuffle
/* 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