$IF 0 Alphabetizing a list in PowerBASIC is as easy as invoking the ARRAY SORT statement on any array which contains a list of things to sort, and because PowerBASIC allows you to create arrays up to 640K in size, this is quite a powerful feature, but what if you have to sort a list larger that that (like 100 Megabytes)? You need to sort the data on disk within a random access file. You can use the BUBBLE sort, which is referred to as the "demon of exchange" since it can literally take DAYS to complete, or you can incorporate the "Quick Sort" developed by C.A.R. Hoare, which is the fastest sorting algorithm known to man. Here it is, in PowerBASIC: $ENDIF SUB QUIKSORT(Fi$, Reclen) PUBLIC 'Fi$ is the file, Reclen is the record length OPEN Fi$ FOR BINARY AS #1 QuickSort LOF(1)\Reclen, Reclen CLOSE #1 END SUB SUB QuickSort(Count, Reclen) QuickSort2 0, Count-1, Reclen END SUB SUB QuickSort2(Port, Starboard, Reclen) locate 6,1: PRINT INT(Port/LOF(1)* 1000);"%" i=Port:j=Starboard X$=Item$((Port+Starboard)\2, Reclen) DO DO WHILE Item$(i,Reclen)X$ AND j>Port :DECR j:LOOP IF i<=j THEN CALL SWAPITEMS(i,j,Reclen) INCR i: DECR j: END IF LOOP WHILE i<=J IF Port < j THEN CALL QuickSort2(Port, J, Reclen) IF i < Starboard THEN CALL QuickSort2(i, Starboard, Reclen) END SUB FUNCTION Item$(number, Reclen) SEEK #1, Number*Reclen Get$ 1, Reclen, I$ Item$=I$ END FUNCTION SUB SWAPITEMS(a,b, Reclen) Seek #1, a*Reclen Get$ 1, Reclen, A$ Seek #1, b*Reclen Get$ 1, Reclen, B$ Seek #1, a*Reclen PUT$ #1, B$ Seek #1, b*Reclen PUT$ #1, A$ END SUB