<%
'*********************************
'Function: NewOrder(ArrStr)
'Arguments: Rstr, a comma-separated array of numbers
'Author: Alixi
'Date: 2007/7/13
'Description: Reordering array of numbers
'Example: <%=NewOrder("34,53,13,22,38,86,111,23,65")%>
'*********************************
FunctionNewOrder(ArrStr)
Fori=0ToUbound(Split(ArrStr,","))
Ifn>0Then
ArrStr=Replace(ArrStr,n,0)
EndIf
sp=split(ArrStr,",")
n=0
Forj=0Toubound(sp)
Ifint(sp(j))>int(n)Then
n=sp(j)
EndIf
Next
NewOrder=NewOrder&replace(n,0,"")&""
Next
NewOrder=NewOrder
EndFunction
%>
Reorder the array
The code copy is as follows:
<%
'*********************************
'Function: NewOrder(sz)
'Arguments: Rstr, a comma-separated array of numbers
'Author: Alixi
'Date: 2007/7/13
'Description: Reorder the array
'Example: <%=NewOrder("34,53,13,22,38,86,111,23,65")%>
'*********************************
FunctionNewOrder(sz)
Dimali,icount,i,ii,j,itemp
ali=split(sz,",")
icon=UBound(ali)
Fori=0Toicode
Forj=iquant-1ToiStep-1
Ifj+1<=UBound(ali)Then
Ifint(ali(j))<int(ali(j+1))Then
Itemp=ali(j)
ali(j)=ali(j+1)
ali(j+1)=itemp
EndIf
EndIf
Next
Next
Forii=0toUbound(ali)
Ifi=Ubound(ali)Then
NewOrder=NewOrder&ali(ii)
Else
NewOrder=NewOrder&ali(ii)&","
EndIf
Next
EndFunction
%>