//SortHibbardInt Hibbard算法,间隔为2^k-1 funcSortHibbardInt(a []int)([]int, int) { n, i := 0, 0 aLen := len(a) for i = 1; i <= aLen-1; i = i*2 + 1 { } //定义间隔 for ; i > 0; i = (i - 1) / 2 { // println(i) //插入排序 for j := i; j < aLen; j++ { tmp := a[j] k := j for ; k >= i && tmp < a[k-i]; k = k - i { a[k] = a[k-i] n++ } a[k] = tmp } } return a, n }