Community discussion forum

Sorting Algorithms

This is a comment thread discussing Sorting Algorithms
  • 10 years ago

    This thread is for discussions of Sorting Algorithms.

  • 7 years ago
    Good, very good.
    this program show me how Qsort works

    Thanks
  • 4 years ago

    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

  • 2 years ago

    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

  • 1 year ago

    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

Post a reply

Enter your message below

Sign in or Join us (it's free).

Want to stay in touch with what's going on? Follow us on twitter!