07-23-2014, 11:20 PM
Code:
sort = Array(10,5,20,35,15)
smallest = sort(0) 'Assuming
greatest = sort(0) 'Assuming
For i = 1 To UBound(sort)
'Looking for smallest
If sort(i) < smallest then
smallest = sort(i)
small_index = i
End If
'Looking for greatest
If sort(i) > greatest then
greatest = sort(i)
great_index = i
End If
Next
'Swapping Values
sort(small_index) = greatest
sort(great_index) = smallest
'Just confirming
For y = o To 4
msgbox sort(y)
Next