数组数据排序的程序例子
发布时间:2006-10-14 2:39:46   收集提供:gaoqian
数组数据排序的程序例子



<%
''*** build example array to show that this thing can sort
''*** alpha-numeric arrays
Dim MyArray
MyArray = Array(1,5,"shawn","says","hello"2m骺噃嶤123,12,98)
MyArray = Sort(MyArray)
For I = 0 to Ubound(MyArray)
Response.Write MyArray(I) & "<br>" & vbCRLF
Next
Response.End


''*** Sorter Function that takes an array and sorts it
Function Sort(ary)
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
%>  

 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50