Library code snippets
Sorting Algorithms
This sample code is a VB6 Project that will show you exactly what a sort looks like. The Quicksort algorithm is included along with the Selection Sort. Both of these sorts are extremely fast, but they can be compared in this program easily. In addition to the Quicksort, a Quicksort for sorting 2-dimensional arrays is included. It works just like the quicksort, only you can sort an array according to one of the dimensions, and the other dimension will sort along with it, so nothing is scrambled. An Array of Progress Bars is also included, so that the Bubble Sort could be seen, and an option for slowing down the Quicksort and Selection Sort is included so you can see both of these on the ProgressBar Array. I hope this basic sample code will help some of you looking for way to sort things out. Good luck.
Related articles
Related discussion
-
Run-time error '91'
by converter2009 (1 replies)
-
VB6 Runtime error 381 subsript out of range Error
by Uncle (2 replies)
-
passing and reading parameters from using Shell
by jigartoliya (0 replies)
-
Convert C++ code to VB6
by mawcot (4 replies)
-
listbox scrollbar
by Dennijr (10 replies)
Related podcasts
-
Christian Beauclair
14 mai 2008 (�mission #0074) ::.Christian Beauclair: Stratégies de migration VB6 vers .NET Nous discutons avec Christian Beauclair des stratégies de migration VB6 vers .NET. Entre autres, nous discutons comment utiliser le "VB 6 Code Advisor" et le "Interop Forms Toolkit" pour ajouter la puiss...
yes. the dimension you provided to sort was based on base 1 not base 0. the correct array dimension to sort by is 0 not 1 and then it works.
also, your array s/b dimmed as 3,1 not 4,2 since it is zero based.
so change to:
ReDim MYARRAY(3, 1)
QuickSort33(MYARRAY, 0, 1, 0, 3)
and all is well
You know, I thought this is very nice. I've tried to get the 2-dim sort working, but I can't. It seems the Quicksort33 algoritm does something nasty with the last 2 parameters,the Lbound and Ubound values of the array. I am trying and trying, no such luck sofar.
This is the script I use, DIMmed the initial array in FormLoad:
Private Sub Command1_Click()
ReDim MYARRAY(4, 2) As String
MYARRAY(0, 0) = "FE"
MYARRAY(0, 1) = "DE"
MYARRAY(1, 0) = "AC"
MYARRAY(1, 1) = "KL"
MYARRAY(2, 0) = "AB"
MYARRAY(2, 1) = "KL"
MYARRAY(3, 0) = "BC"
MYARRAY(3, 1) = "CD"
Debug.Print LBound(MYARRAY, 1) & LBound(MYARRAY, 2)
Debug.Print UBound(MYARRAY, 1) & UBound(MYARRAY, 2)
For i = 0 To 3
strmsg = ""
For j = 0 To 1
strmsg = strmsg & MYARRAY(i, j) & ","
Next j
Debug.Print strmsg
Next i
Call QuickSort33(MYARRAY, 1, 2, 0, 4)
Debug.Print "Sorted"
For i = 0 To 3
strmsg = ""
For j = 0 To 1
strmsg = strmsg & MYARRAY(i, j) & ","
Next j
Debug.Print strmsg
Next i
End Sub
As you can see the sorted array is not sorted correctly. Am I doing anything wrong here?
TIA,
FreeHansje
Thanks for this cool sorting algorithm !
If someone got a sample for the QuickSort33 too it wood be great.
If not i will try it on my own ..
Thanks JS
this program show me how Qsort works
Thanks
This thread is for discussions of Sorting Algorithms.