programming-examples/asp/ActiveX_ADO_Arrays/SelectionSort Function.asp

22 lines
643 B
Plaintext
Raw Permalink Normal View History

2019-11-18 14:25:58 +01:00
<%
Private Function SelectionSort(ByVal unsortedarray)
Dim Front, Back, I, Loc, Selcom
Dim Temp, Selswap, Arrsize
Arrsize = UBound(unsortedarray)
For Front = 0 To Arrsize - 1
Loc = Front
For Back = Front To Arrsize
Selcom = Selcom + 1
If unsortedarray(Loc) > _
unsortedarray(Back) Then
Loc = Back
End If
Next
Selswap = Selswap + 1
Temp = unsortedarray(Loc)
unsortedarray(Loc) = unsortedarray(Front)
unsortedarray(Front) = Temp
Next
SelectionSort = unsortedarray
End Function
%>