ArrayList.prototype.shellSort = function () { let length = this.array.length let gap = Math.floor(length / 2) while (gap >= 1) { for (let i = gap; i < length; i++) { let temp = this.array[i] let j = i; while (temp < this.array[j - gap] && j > gap - 1) { this.array[j] = this.array[j - gap] j -= gap } this.array[j] = temp } gap = Math.floor(gap / 2) } }
原文:https://www.cnblogs.com/creationMarvel/p/14918082.html