<%
dim numamt, nummax, nummin, ar(100), tmp, j
numamt = 5 : nummax = 100 : nummin = 50
response.write("Before sorted by insertion sort<br>")
randomize
for i = 1 to numamt
ar(i) = int(nummin + (rnd * ( nummax - nummin + 1 )))
response.write( i & " : " & ar(i) & "<br>")
next
for i = 2 to numamt
tmp = ar(i)
j = i - 1
do while (tmp < ar(j)) and (j > 0)
ar(j + 1) = ar(j)
j = j - 1
loop
ar(j + 1) = tmp
next
response.write("<hr>After sorted by insertion sort<br>")
for i = 1 to numamt
response.write( i & " : " & ar(i) & "<br>")
next
%>
จำนวน : 25 บรรทัด