|
|
|
Click here to copy the following block |
Sub ShellSort(arr As Variant, Optional lastEl As Variant, _ Optional descending As Boolean) Dim value As Variant Dim index As Long, index2 As Long Dim firstEl As Long Dim distance As Long Dim numEls As Long
If IsMissing(lastEl) Then lastEl = UBound(arr) firstEl = LBound(arr) numEls = lastEl - firstEl + 1 Do distance = distance * 3 + 1 Loop Until distance > numEls
Do distance = distance \ 3 For index = distance + firstEl To lastEl value = arr(index) index2 = index Do While (arr(index2 - distance) > value) Xor descending arr(index2) = arr(index2 - distance) index2 = index2 - distance If index2 - distance < firstEl Then Exit Do Loop arr(index2) = value Next Loop Until distance = 1 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 ) |
|
|