Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sorting arrays

Status
Not open for further replies.

kathyc20

Programmer
Mar 7, 2001
96
CA
I have an array containing 35 numeric values.

How would I go about sorting these?

 
There is a ton of methods. Just Google. Here is a simple one

Public Function SortArray(ByRef TheArray As Variant)
Sorted = False
Do While Not Sorted
Sorted = True
For X = 0 To UBound(TheArray) - 1
If TheArray(X) > TheArray(X + 1) Then
Temp = TheArray(X + 1)
TheArray(X + 1) = TheArray(X)
TheArray(X) = Temp
Sorted = False
End If
Next X
Loop
End Function

Larger arrays use much more complicated algorithms such as binary and heaps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top