var arr=[9,3,1,2,5,8,4,7,6,0];arr.sort();document.write("正常排序后的数组元素:"+arr.join(",")+"<BR />");正常排序后的数组元素:0,1,2,3,4,5,6,7,8,9
function randomSort(a, b){return Math.random() - 0.5;}arr.sort(randomSort);document.write("随机排序后的数组元素:"+arr.join(",")+"<BR />");随机排序后的数组元素:3,1,7,4,8,6,2,0,9,5