Skip to content

Instantly share code, notes, and snippets.

@jgarciaruiz
Created February 10, 2016 10:46
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 jgarciaruiz/e8194e8108ea593f818d to your computer and use it in GitHub Desktop.
Save jgarciaruiz/e8194e8108ea593f818d to your computer and use it in GitHub Desktop.
//@ http://jsfromhell.com/array/shuffle
shuffle = function(v){
for(var j, x, i = v.length; i; j = parseInt(Math.random() * i), x = v[--i], v[i] = v[j], v[j] = x);
return v;
};
//example:
var a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
shuffle(a);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment