<script> function randomsort(a, b) { return Math.random()>.5 ? -1 : 1; } var arr = [0,1,2,3,4,5,6]; var arr2 = arr.sort(randomsort); alert(arr2);</script>