10 CLS :KEY OFF: LOCATE 1,32 :PRINT "QuickSort"
20 N=100 : R=VAL(RIGHT$(TIME$,2)) :RANDOMIZE R
30 PRINT :PRINT " Generating array of";N;"random numbers to be sorted : RANDOMIZE (";R;")
40 C1 = 0 : S1 = 0
50 DIM X(500),S9(20,2)
60 FOR K=1 TO N
70 LET X(K) = INT(22*RND)
80 NEXT K
90 PRINT
100 GOSUB 330
102 PRINT :PRINT " Now sorting the array " : ROW=CSRLIN-1
105 DEF FNT(D)=VAL(MID$(TIME$,7,2))+VAL(MID$(TIME$,4,2))*60 +VAL(MID$(TIME$,1,2))*3600
107 TM1=FNT(D) ' ********** Start Timer ************
110 I1=1 : J1 = N
120 I=I1 : J = J1 : S = -1
130 C1=C1 + 1
140 IF X(I)<=X(J) THEN 180
150 S1 = S1 + 1
160 T=X(I) : X(I)=X(J) : X(J)=T
170 S=SGN(-S)
180 IF S=1 THEN I=I+1 ELSE J=J-1
190 IF I= J1 THEN 220
210 P=P+1 : S9(P,1)= I + 1: S9(P,2)= J1
220 J1 = I - 1
230 IF I1=10 THEN PRINT
370 NEXT K
380 RETURN
390 END