Sorter array ASC
Hejsa..Jeg har et lille problem med at få sorteret outputtet fra arrayet korrekt.
<%
xsel = "mnuChk=25&mnuChk=14&mnuChk=20&mnuChk=45&mnuChk=25&mnuChk=4&mnuChk=1&mnuChk=31&mnuChk=22&mnuChk=7"
Response.write "The input values are those ones: <BR>"
Response.write xsel
myArr = Split(xsel,"&")
xSubMenuID = ""
'-- Split arr into id numbers and add to string ---------------
for i = 0 to uBound(myArr)
If Left(myArr(i),6) = "mnuChk" Then
myArrIn = Split(myArr(i),"=")
tempArr = tempArr & myArrIn(1) & ","
End If
Next
'-- Remove , at the end ---------------------------------------
If Right(tempArr, 1) = "," Then
tempArr = Left(tempArr, (Len(tempArr) - 1))
End If
'-- Unsorted values -------------------------------------------
Response.write "<BR><BR>The unsorted values are those ones: <BR>"
Response.write tempArr
'-- Sort the Unsorted values ----------------------------------
tempArrX = Array(tempArr)
max=ubound(tempArrX)
For i=0 to max
For j=i+1 to max
if tempArrX(i)>tempArrX(j) then
TemporalVariable=tempArrX(i)
tempArrX(i)=tempArrX(j)
tempArrX(j)=TemporalVariable
end if
next
next
'-- Sorted values ---------------------------------------------
Response.write "<BR><BR>The sorted values are those ones: <BR>"
For i=0 to max
Response.write tempArrX(i) & "<BR>"
next
%>
Hvis jeg bruger mit genererede array tempArrX = Array(tempArr) så får jeg et output: 25,14,20,45,25,4,1,31,22,7
Men hvis jeg sætter id numrene ind i arrayet selv tempArrX = Array(25,14,20,45,25,4,1,31,22,7) så får jeg det output jeg skal bruge..
Hvorfor vil sorterings arrayet ikke gendkende mit autogen array???