var arr = [1,2,3,4,5];
function randomsort(a, b) {
   return Math.random()>.5 ? -1 : 1; //通过随机产生0到1的数,然后判断是否大于0.5从而影响排序,产生随机性的效果。
}
arr.sort(randomsort);
console.log(arr);