Hi, if I have an array of say 50 numbers.
how do I get the Biggest Number, Smallest number and
sort them into assending or desending order
thanks
MICK
Printable View
Hi, if I have an array of say 50 numbers.
how do I get the Biggest Number, Smallest number and
sort them into assending or desending order
thanks
MICK
Go look at this thread.
You should search the forum before asking a question,
just a tip
There are a lot of ways to sort an array. The bubble sort is the easiest. It's also the slowest. But if the arrays aren't too big, speed doesn't really matter. To do a bubble sort:
Code:Dim List(1 To 5) As String 'the array
Dim Swap As String 'temporary
Dim I As Integer 'for loops
Dim J As Integer 'for loops
List(1) = "Hello"
List(2) = "Bye"
List(3) = "Lala"
List(4) = "Blabla"
List(5) = "Kaboom"
'sort them
For I = 1 To UBound(List)
'the bubble sort moves large values to the top
For J = 1 To UBound(List) - 1
'compare them
If List(J) > List(J + 1) Then
'list(x)>list(x+1)
Swap = List(J + 1)
List(J + 1) = List(J)
List(J) = Swap
End If
Next
Next
Oetje :
Alpha and numeric are different sorts. My post, the one above yours on this thread, demonstates a numeric bubble sort....if interested.
Good code HeSaidJoe, but you should comment it.:p