I'm wandering if someone can give me the pseaudo code for sorting a range of numbers.Easiest sorting method if possible.
Printable View
I'm wandering if someone can give me the pseaudo code for sorting a range of numbers.Easiest sorting method if possible.
That will automatically sort them, or if you want the user to put them in a list:Code:Needed: Listbox
For i = 0 to 10 'count 0 to number 10
list1.additem i 'add to list
Next i 'loop till 10
list1.additem "1"
list1.additem "6"
list1.additem "5"
list1.additem "3"
list1.additem "10"
list1.additem "7"
list1.additem "2"
list1.additem "9"
list1.additem "8"
list1.additem "4"
Set the properties list sorted to True.
This will sort your array as fast as possible:
Also for sorting numbers withour loosing the order as above, use format function:Code:Sub Sort(a() As String)
Dim n&, i&, j&, k&, h
n = UBound(a)
k = n \ 2
While k > 0
For i = 0 To n - k
j = i
While (j >= 0) And (a(j) > a(j + k))
h = a(j)
a(j) = a(j + k)
a(j + k) = h
If j > k Then
j = j - k
Else
j = 0
End If
Wend
Next i
k = k \ 2
Wend
End Sub
Code:Msgbox Format("12","0000")