function shuffle(array) {
var currentIndex = array.length, temporaryValue, randomIndex;
while (0 !== currentIndex) {
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}
return array;
}
alert(shuffle([1,2,3,4,5,6,7,8,9]));
описание метода
https://en.wikipedia.org/wiki/Fisher...3Yates_shuffle
Fisher–Yates Shuffle Visualization