Skip to content

Instantly share code, notes, and snippets.

View shaundillon's full-sized avatar

Dillbotnik shaundillon

View GitHub Profile
@shaundillon
shaundillon / gist:b2414c9eef3b92f3910b
Created March 23, 2015 14:21
Fisher-Yates JS implementation
function shuffle(array) {
var unshuffled = array.length,
copy,
remaining;
// While there are unshuffled elements
while (unshuffled) {
// Get one that hasn't been replaced yet
remaining = Math.floor(Math.random() * unshuffled--);
// And replace it with the unshuffled element
p 40