Sub Sort_A(lngOld() As Long)
'*****
'* Sort Old ascending
'*****
Dim I As Long, _
J As Long, _
lngN As Long, _
lngGAP As Long, _
JGap As Long, _
wLng As Long
Dim lngNo As Long
lngNo = UBound(lngOld)
Dim w1st As Long, _
w2nd As Long, _
w1stGap As Long, _
w2ndGap As Long
' S H E L L S O R T
lngN = lngNo
lngGAP = 1
Do While (lngGAP < lngN)
lngGAP = lngGAP * 3 + 1
Loop
lngGAP = (lngGAP - 1) \ 3
Do While lngGAP > 0
For I = lngGAP + 1 To lngN
J = I - lngGAP
JGap = J + lngGAP
Do While J > 0
w1st = lngOld(J) ' ABSolute value
If w1st < 0 Then w1st = -w1st
w1stGap = lngOld(JGap)
If w1stGap < 0 Then w1stGap = -w1stGap
JGap = J
J = J - lngGAP
Loop
Next
If lngGAP <= 1 Then Exit Do
lngGAP = (lngGAP - 1) \ 3
Loop
'For I = 2 To UBound(lngOld)
' Debug.Print "Old=" & lngOld(I)
'Next
End Sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.