Gosub Setup Print "Sort Process Started..." T = Timer() Rem ###################################################################################### Rem Place All Your Entry Code In This Section Between The #### Lines. Make Sure That When Rem Your Code Is Finished The 'Elapsed = Timer() - T' Line is executed. quicksort(0,272) Rem ###################################################################################### Elapsed = Timer() - T : Rem Calculate Time Elapsed During Sort Print "Sort Process Completed..." Gosub SaveSortedList: Rem Write Sorted Array To Text File Print Print "Sorted File Written To Text File 'Sorted.txt'. Sort Time: ";Str$(Elapsed);" ms" End: Rem Program End Rem ************************************************************************************** Rem *** Procedures *** Rem ************************************************************************************** Setup: Sync On: Sync Rate 0 Dim NameList$(280) Open To Read 1,"NameList.txt" For FileNum = 0 To 272 Read String 1,NameList$(FileNum) Next FileNum Close File 1 Center Text 320,150,"273 Names Read Into Array NameList(0 .. 272)" Center Text 320,200, "Press The Space Bar To Commence Sort..." Repeat Sync Until SpaceKey()=1 CLS Return SaveSortedList: If File Exist("Sorted.txt") Then Delete File "Sorted.txt" Open To Write 1,"Sorted.txt" For FileNum = 0 To 272 Write String 1,NameList$(FileNum) Next FileNum Write String 1,"Time Taken: "+Str$(Elapsed)+" ms" Close File 1 Return Rem Place Any Procedures Required By Your Program Here: Rem ************************************************************************************** Rem *** Functions *** Rem ************************************************************************************** Rem Place Any Functions Required By Your Program Here: function quicksort(start,finish) p = start pv$=namelist$(p) for i = (start + 1) to finish if namelist$(i) < pv$ namelist$(p) = namelist$(i) namelist$(i) = namelist$(p+1) namelist$(p+1) = pv$ inc p endif next i if p - start >= 2 then quicksort(start, p - 1) if finish - p >= 2 then quicksort(p + 1, finish) endfunction