funcshellSort(arr []int) { N := len(arr) gap := N / 2 for gap >= 1 { for i := gap; i < N; i++ { for j := i; j > gap && less(arr[j], arr[j-gap]); j -= gap { fmt.Println(arr[j], arr[j-gap]) exch(arr, j, j-gap) } } fmt.Println(gap) gap = gap / 2 }
}
funcless(a, b int)bool { return a < b }
funcexch(arr []int, i, min int) { arr[i], arr[min] = arr[min], arr[i] }