View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
jimmyp[_2_] jimmyp[_2_] is offline
external usenet poster
 
Posts: 1
Default sort function - from ascending to descending


hi

i have this bubblesort sub -


Code:
--------------------

Sub BubbleSort(List() As Integer)

Dim First As Integer, Last As Integer
Dim i As Integer, j As Integer
Dim Temp As Integer

First = LBound(List)
Last = UBound(List)
For i = First To Last - 1
For j = i + 1 To Last
If List(i) List(j) Then
Temp = List(j)
List(j) = List(i)
List(i) = Temp
End If
Next j
Next i
End Sub


--------------------


but at the moment it sorts all the elements in ascending order, and i
need it biggest element first ie. descending...

any idea how i change it, i guess it would be simple but i suppose it
may need completely rewriting

thanks


jimmyp


--
jimmyp
------------------------------------------------------------------------
jimmyp's Profile: http://www.excelforum.com/member.php...o&userid=32217
View this thread: http://www.excelforum.com/showthread...hreadid=522186