ExchangeSort Function:
Sorts an array alphabetically (A - Z) or numerically (low to high).
Description:
The ExchangeSort function sorts an array alphabetically (A - Z) or numerically (low to high). ExchangeSort expects an array as input.
Syntax:
array = ExchangeSort(unsortedarray)
Example:
<%
Dim Item For Each Item In ExchangeSort( Array( "jonny", "steve", "bill", "brian", "alfred" ) ) Response.Write Item & "<BR>" Next ' returns: ' alfred ' bill ' brian ' jonny ' steve
Dim Item For Each Item In ExchangeSort( Array( 512, 10, 81, 6, 452 ) ) Response.Write Item & "<BR>" Next ' returns: ' 6 ' 10 ' 81 ' 452 ' 512
%>
ASP Source Code:
<%
Private Function ExchangeSort(byVal unsortedarray) Dim Front, Back, I, Temp, Arrsize, Excom, Exswap Arrsize = UBOUND( unsortedarray ) For Front = 0 To Arrsize For Back = Front To Arrsize Excom = Excom + 1 If unsortedarray(Front) > unsortedarray(Back) Then Temp = unsortedarray(Front) unsortedarray(Front) = unsortedarray(Back) unsortedarray(Back) = Temp Exswap = Exswap + 1 End If Next Next ExchangeSort = unsortedarray End Function
%>
|