O código que pesquisei online é o mesmo que este
Funções (ARY)
Dimkeepchecking, i, FirstValue, SecondValue
KeepChecking = true
Dountilkeepchecking = false
KeepChecking = false
Fori = 0Toubound (ary)
Ifi = ubound (ary) thenExitfor
Ifary (i)> ary (i+1) então
FirstValue = ary (i)
SecondValue = ary (i+1)
ary (i) = SecondValue
ary (i+1) = FirstValue
KeepChecking = true
Endif
Próximo
Laço
Classy = ary
Função final
Há um erro. . . . . .
Apenas teste
s = "11,3,1"
s = classificar (dividir (s, ",")))
fori = 0Toubund (s)
Response.writes (i) & "<br>"
próximo
O resultado da impressão é
1
11
3
A função correta é:
Funções (ARY)
ck = true
Dountilck = false
ck = false
Forf = 0TOUBOUND (ARY) -1
ifclng (ary (f))> clng (ary (f+1)) então
v1 = clng (ary (f))
v2 = clng (ary (f+1))
ary (f) = v2
ary (f+1) = v1
ck = true
endif
próximo
laço
classy = ary
Função final
Apenas um clng ()
Mas o engraçado é que algumas matrizes podem ser organizadas corretamente usando a função de classificação errada.