希尔排序
function shellsort() {
for (var g = 0; i <
this.gaps.length; ++g) {
for (var i = 0; i < this.dataStore.length; ++i) {
var temp = this.dataStore[i];
for (var j = i; j >= this.gaps[g] && this.dataStore[j-this.gaps[g]] > temp; j -= this.gaps[g]) {
this.dataStore[j] = this.dataStore[j-this.gaps[g]];
}
this.dataStore[j] = temp;
}
}
}this.gaps = [5,3,1];
//并添加一个函数
function setGap(arr) {
this.gaps = arr ;
}最后更新于