10 REM ******CHARACTER STRING / NUMBER SORT******
20 REM   ******FROM CP/M USERS GROUP 5.22******
30 REM      EDITED BY KEITH PETERSEN, W8SDZ
40 CLEAR 500
50 DIM N(150),C$(150)
60 PRINT:PRINT "TYPE C FOR CHARACTER STRING SORT,"
70 PRINT "TYPE N FOR NUMBER SORT.";
80 INPUT W$
90 N=0
100 PRINT
110 IF W$="N" THEN 480
120 IF W$<> "C" THEN 60
130 REM **********CHARACTER STRING SORT ROUTINE***********
140 GOSUB 770
150 INPUT S$
160 PRINT
170 N=N+1
180 INPUT C$(N)
190 IF C$(N)<>S$ THEN 170
200 N=N-1
210 PRINT
220 L=INT(N/2)+1
230 N1=N
240 IF L=1 THEN 280
250 L=L-1
260 A$=C$(L)
270 GOTO 320
280 A$=C$(N1)
290 C$(N1)=C$(1)
300 N1=N1-1
310 IF N1=1 THEN 430
320 J=L
330 I=J
340 J=2*J
350 IF J=N1 THEN 390
360 IF J>N1 THEN 420
370 IF C$(J)>=C$(J+1) THEN 390
380 J=J+1
390 IF A$>=C$(J) THEN 420
400 C$(I)=C$(J)
410 GOTO 330
420 C$(I)=A$:GOTO 240
430 C$(1)=A$
440 FOR I=1 TO N
450 PRINT C$(I):NEXT I
460 GOTO 60
470 REM *************NUMBER SORTING ROUTINE*************
480 GOSUB 770 
490 INPUT S:PRINT
500 N=N+1
510 INPUT N(N)
520 IF N(N)<>S THEN 500
530 N=N-1
540 PRINT
550 L=INT(N/2)+1
560 N1=N
570 IF L=1 THEN 600
580 L=L-1
590 A=N(L):GOTO 630
600 A=N(N1):N(N1)=N(1)
610 N1=N1-1
620 IF N1=1 THEN 730
630 J=L
640 I=J
650 J=2*J
660 IF J=N1 THEN 690
670 IF J>N1 THEN 720
680 IF N(J)<N(J+1) THEN J=J+1
690 IF A>N(J) THEN 720
700 N(I)=N(J)
710 GOTO 640
720 N(I)=A:GOTO 570
730 N(1)=A
740 FOR I=1 TO N:PRINT N(I):NEXT
750 GOTO 60
760 REM **********SUBROUTINE TO INPUT STOP CODE**********
770 PRINT "PLEASE INDICATE A STOP CODE----SOMETHING NOT IN YOUR LIST"
780 PRINT "WHICH WILL ACT AS AN 'END OF LIST' SIGNAL: ";
790 RETURN
800 END
ATE A STOP CODE----SOMETHING NOT IN YOUR LIST"
780 PRINT "WHICH WILL ACT AS AN 'END OF