1.什么是冒泡排序:
2.代码实现:
//交换两个位置数据方法
ArrayList.prototype.swap = function(m, n) {
var temp = this.array[m]
this.array[m] = this.array[n]
this.array[n] = temp
}
//排序算法
//1.冒泡排序
ArrayList.prototype.bubbleOrder = function() {
var length = this.array.length
for (var j = length - 1; j >= 0; j--) {
for (var i =0; i < j; i++ ) {
if (this.array[i]> this.array[i+1]) {
this.swap(i, i+1)
}
}
}
}