Code: [Local Link Removed for Guests]
items = 23
dim N(items)
dim C$(items)
for i = 0 to items
N(i) = rnd(1000)
c$(i) = str$(i)
next i
wlog "Messy: ----------------"
for i = 0 to items
wlog N(i), c$(i)
next i
bubbleSort N(), C$(), items
wlog
wlog "Tidy: -------------------"
for i = 0 to items
wlog N(i), C$(i)
next i
END
' ----------------------------------------
SUB bubbleSort(arrayN(), arrayC$(), items)
LOCAL count, counter
LOCAL p, h$
for count = 0 TO items
for counter = 0 TO items
if arrayN(counter) < arrayN(count) then
p = arrayN(count)
arrayN(count) = arrayN(counter)
arrayN(counter) = p
h$ = arrayC$(count)
arrayC$(count) = arrayC$(counter)
arrayC$(counter) = h$
endif
next counter
next count
END SUB