You have several options.
First, you can use a stupidly naive sorter ...
arr = arr.sort(function() { return Math.random() - .5 });
jsFiddle .
It's quick and dirty, but often considered bad practice.
Further reading .
The best way to randomly sort Array
is through a Fisher-Yates shuffle .
var newArr = []; while (arr.length) { var randomIndex = Math.floor(Math.random() * arr.length), element = arr.splice(randomIndex, 1) newArr.push(element[0]); }
JSBin .
source share