Bagharmin
Board Regular
- Joined
- Nov 22, 2010
- Messages
- 168
I used a version of Quicksort in my code which displays things in ascending order. The code is below:
If I want to have it display in descending order instead, do I need to switch every inequality sign or do I only need to change a select few?
Thanks for the help.
Code:
Private Sub BinarySort(CategoryTypes() As Variant, ByVal iStart As Double, ByVal iEnd As Double)
Dim RunThru As Double, imTiny As Double, imHuge As Double
Dim Half As String, Temp As String
imTiny = iStart
imHuge = iEnd
Half = CategoryTypes((imTiny + imHuge) / 2)
Do While imTiny <= imHuge
Do While (CategoryTypes(imTiny) < Half And imTiny < iEnd)
imTiny = imTiny + 1
Loop
Do While (Half < CategoryTypes(imHuge) And imHuge > iStart)
imHuge = imHuge - 1
Loop
If imTiny <= imHuge Then
Temp = CategoryTypes(imTiny)
CategoryTypes(imTiny) = CategoryTypes(imHuge)
CategoryTypes(imHuge) = Temp
imTiny = imTiny + 1
imHuge = imHuge - 1
End If
Loop
If iStart < imHuge Then Call BinarySort(CategoryTypes(), iStart, imHuge)
If imTiny < iEnd Then Call BinarySort(CategoryTypes(), imTiny, iEnd)
End Sub
If I want to have it display in descending order instead, do I need to switch every inequality sign or do I only need to change a select few?
Thanks for the help.