Skip to content

Instantly share code, notes, and snippets.

@ryansukale
Last active December 25, 2015 05:49
Show Gist options
  • Save ryansukale/6927680 to your computer and use it in GitHub Desktop.
Save ryansukale/6927680 to your computer and use it in GitHub Desktop.
A short snippet to randomize elements in an array or a jquery collection.
function randomize(arr) {
for(var j, x, i = arr.length; i; j = parseInt(Math.random() * i), x = arr[--i], arr[i] = arr[j], arr[j] = x);
return arr;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment