CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2003
    Posts
    417

    Quick Sort code needed

    I need the Quick Sort code for sorting an array.

  2. #2
    Join Date
    Jan 2002
    Location
    Quebec/Canada
    Posts
    124
    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

  3. #3
    Join Date
    Aug 2001
    Posts
    1,447

    Re: Quick Sort code needed

    Originally posted by Sathyaish
    I need the Quick Sort code for sorting an array.
    VB quicksort is posted on the link below my name
    phinds
    vs2008, 3.5SP1 Version 9.0.21022.8 RTM

  4. #4
    Join Date
    Feb 2003
    Posts
    417
    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.

  5. #5
    Join Date
    Jan 2002
    Location
    Quebec/Canada
    Posts
    124
    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 !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured