SelectionSort Function:

The SelectionSort function sorts an array alphabetically (A - Z) or numerically (low to high). SelectionSort expects an array as input.

Syntax:
array = SelectionSort(unsortedarray)
Example Usage:
<%
Dim Item
For Each Item In SelectionSort( Array( "jonny", "steve", "bill", "brian", "alfred" ) )
	Response.Write Item & "<BR>"
Next
 ' returns:
 '   alfred
 '   bill
 '   brian
 '   jonny
 '   steve


Dim Item
For Each Item In SelectionSort( Array( 512, 10, 81, 6, 452 ) )
	Response.Write Item & "<BR>"
Next
 ' returns:
 '   6
 '   10
 '   81
 '   452
 '   512
%>
ASP Source Code:
<%
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
%>