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