程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> ASP編程 >> 關於ASP編程 >> ASP教程:數組數據排序的程序例子

ASP教程:數組數據排序的程序例子

編輯:關於ASP編程

<%
'*** build example array to show that this thing can sort
'*** alpha-numeric arrays
Dim MyArray
MyArray = Array(1,5,"shawn","says","hello",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. 下一頁:
Copyright © 程式師世界 All Rights Reserved