【正文】
p 39。Move the node lngArray(iCurrent + iLBound) = iElement Next iRoot 39。Copy from temp array to real array For iRoot = iLBound To iUBound lngArray(iRoot) = arrOut(iRoot) Next iRootEnd Sub7 組合排序Public Sub CombSort(ByRef lngArray() As Long) Dim iSpacing As Long Dim iOuter As Long Dim iInner As Long Dim iTemp As Long Dim iLBound As Long Dim iUBound As Long Dim iArrSize As Long Dim iFinished As Long iLBound = LBound(lngArray) iUBound = UBound(lngArray) 39。Initialise b width iSpacing = iUBound iLBound Do If iSpacing 1 Then iSpacing = Int(iSpacing / ) If iSpacing = 0 Then iSpacing = 1 39。Dont go lower than 1 ElseIf iSpacing 8 And iSpacing 11 Then iSpacing = 11 39。This is a special number, goes faster than 9 and 10 End If End If 39。Always go down to 1 before attempting to exit If iSpacing = 1 Then iFinished = 1 39。Combing pass For iOuter = iLBound To iUBound iSpacing iInner = iOuter + iSpacing If lngArray(iOuter) lngArray(iInner) Then 39。Swap iTemp = lngArray(iOuter) lngArray(iOuter) = lngArray(iInner) lngArray(iInner) = iTemp 39。Not finished iFinished = 0 End If Next iOuter Loop Until iFinishedEnd Sub8 希爾排序Public Sub ShellSort(ByRef lngArray() As Long)Dim iSpacing As LongDim iOuter As LongDim iInner As LongDim iTemp As LongDim iLBound As LongDim iUBound As LongDim iArrSize As LongiLBound = LBound(lngArray)iUBound = UBound(lngArray)39。Calculate initial sort spacingiArrSize = (iUBound iLBound) + 1iSpacing = 1If iArrSize 13 ThenDo While iSpacing iArrSizeiSpacing = (3 * iSpacing) + 1LoopiSpacing = iSpacing \ 9End If39。Start sortingDo While iSpacingFor iOuter = iLBound + iSpacing To iUBound39。Get the value to be insertediTemp = lngArray(iOuter)39。Move along the already sorted values shifting alongFor iInner = iOuter iSpacing To iLBound Step iSpacing39。No more shifting needed, we found the right spot!If lngArray(iInner) = iTemp Then Exit ForlngArray(iInner + iSpacing) = lngArray(iInner)Next iInner39。Insert value in the slotlngArray(iInner + iSpacing) = iTempNext iOuter39。Reduce the sort spacingiSpacing = iSpacing \ 3LoopEnd Sub9 基數(shù)排序Public Sub RadixSort(ByRef lngArray() As Long) Dim arrTemp() As Long Dim iLBound As Long Dim iUBound As Long Dim iMax As Long Dim iSorts As Long Dim iLoop As Long iLBound = LBound(lng