Skip to content

Instantly share code, notes, and snippets.

@pixeloution
Created August 13, 2018 15:01
Show Gist options
  • Save pixeloution/cf2a3e0792f84a702f9f08f272594557 to your computer and use it in GitHub Desktop.
Save pixeloution/cf2a3e0792f84a702f9f08f272594557 to your computer and use it in GitHub Desktop.
Fisher-Yates Shuffle
function shuffle(a) {
var j, x, i;
for (i = a.length - 1; i > 0; i--) {
j = Math.floor(Math.random() * (i + 1));
x = a[i];
a[i] = a[j];
a[j] = x;
}
return a;
}
@pixeloution
Copy link
Author

Don't worry about understanding this, we'll cover it later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment