Skip to content

Instantly share code, notes, and snippets.

@yuheiy
Last active August 29, 2015 14:27
Show Gist options
  • Save yuheiy/822fb8ae0062e15c630c to your computer and use it in GitHub Desktop.
Save yuheiy/822fb8ae0062e15c630c to your computer and use it in GitHub Desktop.
shuffle arranges in javascript. Fisher-Yates.
function shuffle(list) {
var i = list.length;
while (--i) {
var j = Math.floor(Math.random() * (i + 1));
if (i == j) continue;
var k = list[i];
list[i] = list[j];
list[j] = k;
}
return list;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment