The code I searched online is the same as this one
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
There is an error. . . . . .
Just test it out
s="11,3,1"
s=sort(split(s,","))
fori=0toubund(s)
response.writes(i)&"<br>"
next
The print result is
1
11
3
The correct function is:
functionsort(ary)
ck=true
doUntilck=false
ck=false
Forf=0toUBound(ary)-1
ifclng(ary(f))>clng(ary(f+1))then
v1=clng(ary(f))
v2=clng(ary(f+1))
ary(f)=v2
ary(f+1)=v1
ck=true
endif
next
loop
sort=ary
endfunction
Just one clng()
But what's funny is that some arrays can be arranged correctly using the wrong sort function.