I need the Quick Sort code for sorting an array.
Printable View
I need the Quick Sort code for sorting an array.
I'm sure you can find some nice sort code on this forum with a simple search. Anyway, Here's the shell sort :
Code:Dim Inter As Double
Dim iCtr As Double
Dim iCtr2 As Double
Dim bEnd As Boolean
Dim TmpVal As Variant
Inter = UBound(aRecord)
While (Inter > 1)
Inter = Inter \ 2
Do
bEnd = True
For iCtr = 1 To (UBound(aRecord) - Inter)
iCtr2 = iCtr + Inter
' compare values here
If (aRecord(iCtr) > Mod_Def.aRecord(iCtr2)) Then
TmpVal = aRecord(iCtr)
aRecord(iCtr) = aRecord(iCtr2)
aRecord(iCtr2) = TmpVal
bEnd = False
End If
Next iCtr
Loop Until bEnd
Wend
VB quicksort is posted on the link below my nameQuote:
Originally posted by Sathyaish
I need the Quick Sort code for sorting an array.
Thanks a bunch, phinds. And thanks Heulsay, for that code. I shall surely use it when I need shell sort. It is believed that QuickSort is the fastest.
My bad :) I must still be sleeping this morning but i read you were looking for a code that sort quickly !
Have a nice day !