This is a simple bubble sort. How can I make it sort faster.
'*******************************************
Changed% = 0
FOR c% = 2 TO Matches%
SEEK #OutFile%, ((c% - 2) * %QueryLen) + Offset%(KeyField%)
GET$ #OutFile%, FldLen%(KeyField%), Buffer1$
SEEK #OutFile%, ((c% - 1) * %QueryLen) + Offset%(KeyField%)
GET$ #OutFile%, FldLen%(KeyField%), Buffer2$
IF ucASE$(Buffer1$) > UCASE$(Buffer2$) THEN ' we need to swap these records
Changed% = -1 ' we've made a change, so we'll have to make another pass through the file
SEEK #OutFile%, (c% - 2) * %QueryLen
GET #OutFile%, , Record1
GET #OutFile%, , Record2
' swap the records
SEEK #OutFile%, (c% - 2) * %QueryLen
PUT #OutFile%, , Record2
PUT #OutFile%, , Record1
END IF
NEXT c%
LOOP WHILE Changed%
' the file is now sorted, so print the report
------------------
'*******************************************
Changed% = 0
FOR c% = 2 TO Matches%
SEEK #OutFile%, ((c% - 2) * %QueryLen) + Offset%(KeyField%)
GET$ #OutFile%, FldLen%(KeyField%), Buffer1$
SEEK #OutFile%, ((c% - 1) * %QueryLen) + Offset%(KeyField%)
GET$ #OutFile%, FldLen%(KeyField%), Buffer2$
IF ucASE$(Buffer1$) > UCASE$(Buffer2$) THEN ' we need to swap these records
Changed% = -1 ' we've made a change, so we'll have to make another pass through the file
SEEK #OutFile%, (c% - 2) * %QueryLen
GET #OutFile%, , Record1
GET #OutFile%, , Record2
' swap the records
SEEK #OutFile%, (c% - 2) * %QueryLen
PUT #OutFile%, , Record2
PUT #OutFile%, , Record1
END IF
NEXT c%
LOOP WHILE Changed%
' the file is now sorted, so print the report
------------------
Comment