Skip to content

Instantly share code, notes, and snippets.

@gasolin
Last active December 20, 2015 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gasolin/6161823 to your computer and use it in GitHub Desktop.
Save gasolin/6161823 to your computer and use it in GitHub Desktop.
//shuffles list in-place
//credit http://dtm.livejournal.com/38725.html
function shuffle(list) {
var i, j, t;
for (i = 1; i < list.length; i++) {
j = Math.floor(Math.random()*(1+i)); // choose j in [0..i]
if (j != i) {
t = list[i]; // swap list[i] and list[j]
list[i] = list[j];
list[j] = t;
}
}
}
var gaia_members = ['Yuren','Arthur','Dominic',
'Rex','Steve','Rudy','Alive',
'Evan','Mark','John','Fred','George','Ian','Greg','Jason'];
shuffle(gaia_members)
alert(gaia_members)
@gasolin
Copy link
Author

gasolin commented Aug 6, 2013

you can run directly at http://jsfiddle.net/gasolin/SYYy2/

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