You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
744 B
Plaintext
24 lines
744 B
Plaintext
5 years ago
|
<%
|
||
|
Private Function CombSort(ByVal UnsortedArray)
|
||
|
Dim I, J, Temp, Gap, Swapped
|
||
|
Dim ArrSize, Combcom, Combswap
|
||
|
Const Shrink = 1.3
|
||
|
ArrSize = UBound( UnsortedArray )
|
||
|
Gap = Arrsize - 1
|
||
|
Do
|
||
|
Gap = Int(Gap / Shrink)
|
||
|
Swapped = True
|
||
|
Combcom = Combcom + 1
|
||
|
For J = 0 To Arrsize - Gap
|
||
|
If UnsortedArray(J) > UnsortedArray(J + Gap) Then
|
||
|
Temp = UnsortedArray(J)
|
||
|
UnsortedArray(J) = UnsortedArray(J + Gap)
|
||
|
UnsortedArray(J + Gap) = Temp
|
||
|
Swapped = False
|
||
|
Combswap = Combswap + 1
|
||
|
End If
|
||
|
Next
|
||
|
Loop Until Not Swapped And Gap = 1
|
||
|
CombSort = UnsortedArray
|
||
|
End Function
|
||
|
%>
|