|
|
|
Click here to copy the following block |
Sub CombSort(arr As Variant, Optional numEls As Variant, _ Optional Descending As Boolean) Dim value As Variant Dim index As Long Dim firstItem As Long Dim Gap As Long Dim Swap As Boolean
If IsMissing(numEls) Then numEls = UBound(arr) firstItem = LBound(arr)
Gap = numEls - firstItem + 1 Swap = False
Do While (Gap > 1 Or Swap) If Gap > 1 Then Gap = (10 * Gap) \ 13 If (Gap = 9 Or Gap = 10) Then Gap = 11 Swap = False For index = firstItem To numEls - Gap value = arr(index) If (value > arr(index + Gap)) Xor Descending Then arr(index) = arr(index + Gap) arr(index + Gap) = value Swap = True End If Next Loop End Sub |
|
|
|
Submitted By :
Nayan Patel
(Member Since : 5/26/2004 12:23:06 PM)
|
|
|
Job Description :
He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting. |
View all (893) submissions by this author
(Birth Date : 7/14/1981 ) |
|
|