lazytrucker
Programmer
In order to sort an array I have been using this script (below) however the array data is pulled from an external source and the data often has the same value:
eg. MyArray(25,25,25,5,8,2,40,40) when this is the case the array falls down is there any way I can edit my code below to support numbers that are the same.
<%
MyArray=Array(25,14,20,45,25,4,1,31,22,7)
max=ubound(MyArray)
For i=0 to max
For j=i+1 to max
if MyArray(i)>MyArray(j) then
TemporalVariable=MyArray(i)
MyArray(i)=MyArray(j)
MyArray(j)=TemporalVariable
end if
next
next
Response.write ("The sorted values are those ones: <BR>")
For i=0 to max
Response.write (MyArray(i) & "<BR>")
next
%>
Any Suggestions appreciated,
Cheers LazyTrucker.
eg. MyArray(25,25,25,5,8,2,40,40) when this is the case the array falls down is there any way I can edit my code below to support numbers that are the same.
<%
MyArray=Array(25,14,20,45,25,4,1,31,22,7)
max=ubound(MyArray)
For i=0 to max
For j=i+1 to max
if MyArray(i)>MyArray(j) then
TemporalVariable=MyArray(i)
MyArray(i)=MyArray(j)
MyArray(j)=TemporalVariable
end if
next
next
Response.write ("The sorted values are those ones: <BR>")
For i=0 to max
Response.write (MyArray(i) & "<BR>")
next
%>
Any Suggestions appreciated,
Cheers LazyTrucker.