-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
Description
comb sort
分个组分别冒泡
Array.prototype.combSort = function () {
var factor = 0.8
var gap = this.length
var swapped = true
var i
var temp
while (gap > 1 || swapped) {
if (gap > 1) {
gap = Math.floor(gap * factor)
}
swapped = false
for (i = 0; gap + i < this.length; i++) {
if (this[i] > this[i + gap]) {
temp = this[i]
this[i] = this[i + gap]
this[i + gap] = temp;
swapped = true
}
}
}
return this
}Reactions are currently unavailable