รหัสที่ฉันค้นหาทางออนไลน์เหมือนกับรหัสนี้
FunctionSort (ARY)
Dimkeepchecking, I, FirstValue, SecondValue
Keepchecking = true
dountilkeepchecking = false
Keepchecking = FALSE
fori = 0toubound (ary)
ifi = ubound (ary) thenexitfor
ifary (i)> ary (i+1) แล้ว
FirstValue = ary (i)
secondValue = ary (i+1)
ary (i) = secondValue
ary (i+1) = FirstValue
Keepchecking = true
endif
ต่อไป
วง
sort = ary
endfunction
มีข้อผิดพลาด - - - - -
เพียงแค่ทดสอบออก
s = "11,3,1"
s = sort (split (s, ","))
fori = 0toubund (s)
Response.writes (i) & "<br>"
ต่อไป
ผลการพิมพ์คือ
1
11
3
ฟังก์ชั่นที่ถูกต้องคือ:
FunctionSort (ARY)
ck = true
dountilck = false
ck = false
forf = 0toubound (ary) -1
ifclng (ary (f))> clng (ary (f+1)) แล้ว
v1 = clng (ary (f))
v2 = clng (ary (f+1))
ary (f) = v2
ary (f+1) = v1
ck = true
endif
ต่อไป
วง
sort = ary
endfunction
เพียงหนึ่ง clng ()
แต่สิ่งที่ตลกคือบางอาร์เรย์สามารถจัดเรียงได้อย่างถูกต้องโดยใช้ฟังก์ชั่นการเรียงลำดับผิด