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