<%
dim numamt, nummax, nummin, ar(100), tmp
numamt = 5 : nummax = 100 : nummin = 50
response.write("Before sorted by new bubble sort<br>")
randomize
for i = 1 to numamt
ar(i) = int(nummin + (rnd * ( nummax - nummin + 1 )))
response.write( i & " : " & ar(i) & "<br>")
next
xleft=2 : xright=numamt : xkeep=numamt
do
for j = xright to xleft step -1
if ar(j-1) > ar(j) then
tmp = ar(j-1)
ar(j-1) = ar(j)
ar(j) = tmp
xkeep = j
end if
next
xleft = xkeep + 1
for j = xleft to xright
if ar(j-1) > ar(j) then
tmp = ar(j-1)
ar(j-1) = ar(j)
ar(j) = tmp
xkeep = j
end if
next
xright = xkeep - 1
loop while xleft > xright
response.write("<hr>After sorted by new bubble sort<br>")
for i = 1 to numamt
response.write( i & " : " & ar(i) & "<br>")
next
%>
จำนวน : 35 บรรทัด