<script>
var array = [2, 0, 6, 1, 77, 0, 52, 0, 25, 7];//创建一个空数组
var item = 0;
for (var i = 0; i < array.length; i++) {
for (var j = 0; j < array.length - 1 - i; j++) {
if (array[j] >= array[j + 1]) {
item = array[j];
array[j] = array[j + 1];
array[j + 1] = item;

}
}
}
console.log(array);

JavaScript冒泡排序_排序算法