数组数据排序的程序例子

数组数据排序的程序例子

1   
2''*** build example array to show that this thing can sort   
3''*** alpha-numeric arrays   
4Dim MyArray   
5MyArray = Array(1,5,"shawn","says","hello"2m骺噃嶤123,12,98)   
6MyArray = Sort(MyArray)   
7For I = 0 to Ubound(MyArray)   
8Response.Write MyArray(I) & "

<br/>

 1" & vbCRLF   
 2Next   
 3Response.End   
 4  
 5  
 6''*** Sorter Function that takes an array and sorts it   
 7Function Sort(ary)   
 8KeepChecking = TRUE   
 9Do Until KeepChecking = FALSE   
10KeepChecking = FALSE   
11For I = 0 to UBound(ary)   
12If I = UBound(ary) Then Exit For   
13If ary(I) > ary(I+1) Then   
14FirstValue = ary(I)   
15SecondValue = ary(I+1)   
16ary(I) = SecondValue   
17ary(I+1) = FirstValue   
18KeepChecking = TRUE   
19End If   
20Next   
21Loop   
22Sort = ary   
23End Function   
Published At
Categories with Web编程
Tagged with
comments powered by Disqus