Skip to content

Instantly share code, notes, and snippets.

@blankyao
Created January 19, 2011 03:38
Show Gist options
  • Save blankyao/785647 to your computer and use it in GitHub Desktop.
Save blankyao/785647 to your computer and use it in GitHub Desktop.
shuffle an array in javascript
//+ Jonas Raoni Soares Silva
//@ http://jsfromhell.com/array/shuffle [v1.0]
shuffle = function(o){ //v1.0
for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
return o;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment