Here's my code, loaded with a very small dummy array for test purposes. Any advice gratefully received. Thank you.

Code: Select all
DIM A%(5)
A%() = 39, 2, 7, 144, 5
PRINT "Before:"
FOR I% = 0 TO 5
PRINT A%(I%)
NEXT
FOR I% = 4 TO 0 STEP -1
FOR J% = 0 TO I%
IF A%(J%) > A%(J% + 1) THEN
T% = A%(J%)
A%(J%) = A%(J% + 1)
A%(J% + 1) = T%
ENDIF
NEXT
NEXT
PRINT "After:"
FOR I% = 0 TO 5
PRINT A%(I%)
NEXT
This definitely follows my experimentation. For each additional element, the routine has to perform that number of additional loops (less one). So a single increase of the number of elements from, say, 9 to 10, would require an additional 9 loops - a small number. However, a single increase from 999,999 to 1,000,000 would require an additional 999,999 loops - not to be sniffed at. With the number of elements this high, one could go 'loopy'.
Code: Select all
C% = DIM(array(),DIM(array()))+1
CALL sort%, array(0)
Code: Select all
C% = DIM(array(),DIM(array()))
CALL sort%, array(1)