Asp数组冒泡排序函数

时间:2008-10-07 12:04:59  来源:第二电脑网上收集  作者:

  第二电脑网导读: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 &n...
  正文: Function Sort(ary)
Dim KeepChecking,I,FirstValue,SecondValue
 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
 
dim ID,ArrayID,Myarray,M
ID="55,48,78,10,90"
ArrayID=split(ID,",")
Myarray=Sort(ArrayID)
'排序测试
For M=0 To Ubound(Myarray)
      Response.Write Myarray(M) & "<br>" & vbCRLF
Next
 
'当然也可以用下面的,
Dim Myarray
Myarray=Array(12,10,25,78,45)
Myarray=Sort(ArrayID)
'排序测试
For M=0 To Ubound(Myarray)
      Response.Write Myarray(M) & "<br>" & vbCRLF
Next
'排序测试
"Asp数组冒泡排序函数"由第二电脑网原创提供,转载请注明:http://www.002pc.com/master/College/Programming/ASP/2008-10-07/2955.html


关键字:

关于《Asp数组冒泡排序函数》文章的评论

站内搜索: 高级搜索

热门搜索: Windows style 系统 tr IP QQ CPU 安装 function 注册 if td