Det går att sortera detta:
arr = Array("E5","E1","E3","E2","E4")
continue = true
Do While continue = true
continue = false
For i = 0 To Ubound(arr)
If i = Ubound(arr) Then Exit For
If arr(i) > arr(i+1) Then
temp = arr(i)
arr(i) = arr(i+1)
arr(i+1) = temp
continue = true
End If
Next
Loop
strCoords = Join(arr)
Response.Write(strCoords)
Response.End
Men inte detta:
x = 0
strCoords = ""
For Each str In Request.Form
If Request.Form(str) = 1 then
strCoords = strCoords & "," & str
x = x+1
End If
Next
strCoords = Mid(strCoords,2)
arr = Array(strCoords)
continue = true
Do While continue = true
continue = false
For i = 0 To Ubound(arr)
If i = Ubound(arr) Then Exit For
If arr(i) > arr(i+1) Then
temp = arr(i)
arr(i) = arr(i+1)
arr(i+1) = temp
continue = true
End If
Next
Loop
strCoords = Join(arr)
Response.Write(strCoords)
Response.End
Det funkar helt enkelt inte... värdena hamnar i oordning i allafall. Men det gör det inte på den första koden. Varför?
str innehåller en bokstav (A-J) och ett tal (1-10) :q :q :q