asp编程中,没有系统函数支持asp排序,而我们经常需要使用的数字排序和字符排序、按拼音排序都需要自己去写程序来排序,这里介绍一个asp排序函数。 view sourceprint?01 '排序
02 Function Sort1(ary)
03 Dim KeepChecking,I,FirstValue,SecondValue
04 KeepChecking = TRUE
05 Do Until KeepChecking = FALSE
06 KeepChecking = FALSE
07 For I = 0 to UBound(ary)
08 If I = UBound(ary) Then Exit For
09 If ary(I) > ary(I+1) Then
10 FirstValue = ary(I)
11 SecondValue = ary(I+1)
12 ary(I) = SecondValue
13 ary(I+1) = FirstValue
14 KeepChecking = TRUE
15 End If
16 Next
17 Loop
18 Sort1 = ary
19 End Function
使用方法:
view sourceprint?1 Dim arr
2 arr = Array("a","c","b")
3 arr = Sort1(arr)
4 For i=0 to ubound(arr)
5 Response.Write(arr(i)&"<br />")
6 Next
发表回复