Asp数组冒泡排序函数

80酷酷网    80kuku.com

  函数|排序|数组FunctionSort(ary)
DimKeepChecking,I,FirstValue,SecondValue
 KeepChecking=TRUE
DoUntilKeepChecking=FALSE
 KeepChecking=FALSE
 ForI=0toUBound(ary)
 IfI=UBound(ary)ThenExitFor
  Ifary(I)>ary(I+1)Then
   FirstValue=ary(I)
   SecondValue=ary(I+1)
   ary(I)=SecondValue
   ary(I+1)=FirstValue
   KeepChecking=TRUE
  EndIf
 Next
Loop
 Sort=ary
EndFunction
 
dimID,ArrayID,Myarray,M
ID="55,48,78,10,90"
ArrayID=split(ID,",")
Myarray=Sort(ArrayID)
'排序测试
ForM=0ToUbound(Myarray)
     Response.WriteMyarray(M)&"
"&vbCRLF
Next
 
'当然也可以用下面的,
DimMyarray
Myarray=Array(12,10,25,78,45)
Myarray=Sort(ArrayID)
'排序测试
ForM=0ToUbound(Myarray)
     Response.WriteMyarray(M)&"
"&vbCRLF
Next
'排序测试

分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: