ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 数组数据排序的程序例子(转)

数组数据排序的程序例子(转)

原创 Linux操作系统 作者:jcszjswkzhou 时间:2019-05-13 09:27:04 0 删除 编辑
<%
'*** 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) & "
" & 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
%>


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10294527/viewspace-124728/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2007-08-29

  • 博文量
    3488
  • 访问量
    2601688