ASP关于Split的问题

来源:百度知道 编辑:UC知道 时间:2024/06/04 08:25:08
a="1,7,2,4,8,6,9"
用split(a,",")输出的数组顺序是 1 7 2 4 8 6 9
如何能使顺序变成 1 2 4 6 7 8 9

写的那么麻烦
简单的
<script language="vbscript">
function asc()
dim aa,bb
a=split("1,7,2,4,8,6,9",",")
for i=0 to ubound(a)
aa=a(i)
for j=i+1 to ubound(a)
if aa>a(j) then
bb=a(i)
aa=a(j)
a(i)=a(j)
a(j)=bb
end if
next
next
asc=a
end function
for k=0 to ubound(asc())
document.write asc()(k)+" "
next
</script>

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 a,b,i