asp 数组排序函数

如果排序不对,看看是不是字符串的数组,而没有转化成数字
<%
Function Sort(ary)
Dim KeepChecking,I,FirstValue,SecondValue
KeepChecking = TRUE
Do Until KeepChecking = FALSE
KeepChecking = FALSE
For I = 0 to UBound(ary)
If I = UBound(ary) Then Exit For
If ary(I) > ary(I+1) Then
FirstValue = ary(I)
SecondValue = ary(I+1)
ary(I) = SecondValue
ary(I+1) = FirstValue
KeepChecking = TRUE
End If
Next
Loop
Sort = ary
End Function


ID="197,163,84,136,256,192,282,180,421,325,230,322,145,299,297,222,88,208,232,405,323,131,83,120,100,235,399,268,146,227,243,172,314,324,300,195,153,357,292,344,148,77,399,319,337,341,185,347,293,16"
ArrayID=split(ID,",")
Myarray=Sort(ArrayID)
'排序测试
For M=0 To Ubound(Myarray)
Response.Write Myarray(M) & "<br>" & vbCRLF
Next

%>

你可能感兴趣的:(asp)