|
-
Apr 12th, 2005, 08:55 AM
#1
Thread Starter
New Member
interesting sort
VB
this is a sorting procedure it works by working from the outside in and recursively calling itself on small portions of itself
Sub sort(a() As String, Lb As Double, Ub As Double, r As Integer)
If r > -1 Then
Dim J As Integer
J = (Log(Ub - Lb + 1) / Log(2))
If r > J Then Exit Sub
End If
Dim I As Double
For I = 0 To (Ub - Lb)/2
If a(Lb + I) > a(Ub - I) Then swap a(Lb + I), a(Ub - I)
Next I
If Ub - Lb > 1 Then
sort a(), Lb, Int(Lb + (Ub - Lb) / 2), -1
sort a(), Int(Lb + (Ub - Lb) / 2) + 1, Ub, -1
End If
If r > -1 Then sort a(), Lb, Ub, r + 1
End Sub
Sub swap(ByRef val1, ByRef val2)
temp = val1
val1 = val2
val2 = temp
End Sub
Last edited by MooseGuy; Apr 12th, 2005 at 10:27 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|