Js冒泡排序: //冒泡排序: //相邻元素进行互相交换 var arr1 = [56, 3, 89, 34, 9, 2]; document.write("原数组: "+ arr1 +"<br/>"); function bubbleSort(arr,flag