4 Private Function ShellSeq(ByRef h() As Long, ByVal n As Long)
5 ' establish increment sequence (see Knuth, Vol 3)
17 h(s) = 8 * p1 - 6 * p2 + 1
19 h(s) = 9 * p1 - 9 * p3 + 1
24 Loop While 3 * h(s) < n
26 If s > 0 Then s = s - 1
30 Public Sub ShellSort(ByRef A() As Variant, ByVal Lb As Long, ByVal Ub As Long)
40 s = ShellSeq(seq, Ub - Lb + 1)
43 ' sort by insertion in increments of h
47 For j = i - h To Lb Step -h
48 If A(j) <= t Then Exit For