asp数字或者字符排序函数代码
程序员文章站
2022-05-03 12:41:44
复制代码 代码如下: '排序 function sort1(ary) dim keepchecking,i,firstvalue,secondvalue keepcheck...
复制代码 代码如下:
'排序
function sort1(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
sort1 = ary
end function
dim arr
arr = array("a","c","b")
arr = sort1(arr)
for i=0 to ubound(arr)
response.write(arr(i)&"<br />")
next