织梦CMS - 轻松建站从此开始!

龙舞天翔资料中心

数组数据排序的程序例子

时间:2012-01-25 21:09来源:动网 作者:dalu_ok (大鲁) 点击:
数组数据排序的程序例子

数组数据排序的程序例子

 

<%
''*** 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
%>

(责任编辑:龙舞天翔)
织梦二维码生成器
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片