Trailing-Edge
-
PDP-10 Archives
-
decus_20tap1_198111
-
decus/20-0020/sortme.uti
There are 2 other files named sortme.uti in the archive. Click here to see a list.
100' NAME--SORTMERG
110'
120' DESCRIPTION--SORTS ENTRIES WITH FOUR TERMS. THE FIRST TWO
130' TERMS SHOULD BE ALPHABETIC, THE SECOND TWO SHOULD BE NUMERIC.
140'
150' SOURCE--JACK NEVISON
160'
170' INSTRUCTIONS--DATA SHOULD BE ENTERED IN LINE 1130 BEGINNING WITH THE
180' TOTAL NUMBER OF ENTRIES AND THEN THE ENTRIES IN THE FORM (ALPHA),
190' (ALPHA),(NUMBER),(NUMBER),..... (SEE LINE 1140 FOR AN EXAMPLE).
200' CHANGE THE DIM STATEMENT IN LINE 260 IF YOU HAVE MORE THAN
210' TEN ENTRIES.
220'
230'
240' * * * * * * * * * MAIN PROGRAM * * * * * * * * * * *
250'
260 DIM A$(10),B$(10),C(10,2),A(10),P(10)
270 READ N
280 FOR I = 1 TO N
290 READ A$(I),B$(I),C(I,1),C(I,2)
300 LET A(I)=I
310 REM A(I) IS THE SHUFFLE FILE THAT KEEPS TRACK OF THE SORTED
320 REM ORDER.(SEE ALSO THE GOSUB ROUTINE IN 2000)
330 NEXT I
340 PRINT"WHICH TERM IS TO BE SEQUENCED, 1,2,3 OR 4";
350 INPUT P1
360 IF P1> 4 THEN 380
370 GO TO 400
380 PRINT "NO INPUT LARGER THAN FOUR IS ALLOWED. RETYPE IT";
390 GOTO340
400 PRINT "WHICH OTHER TERMS TO BE PRINTED";
410 MAT INPUT P
420
430 REM THE SORT ROUTINE
440
450 FOR J = 1 TO N-1
460 FOR I=1 TO N-1
470 ON P1 THEN 480, 530,590,620
480 IF A$(I)<=A$(I+1) THEN 680
490 LET W$=A$(I)
500 LET A$(I)=A$(I+1)
510 LET A$(I+1)=W$
520 GOTO 670
530 REM
540 IF B$(I)<=B$(I+1) THEN 680
550 LET W$=B$(I)
560 LET B$(I)=B$(I+1)
570 LET B$(I+1)=W$
580 GO TO 670
590 REM
600 LET D=1
610 GO TO 630
620 LET D=2
630 IF C(I,D)<=C(I+1,D) THEN 680
640 LET W1=C(I,D)
650 LET C(I,D)=C(I+1,D)
660 LET C(I+1,D)=W1
670 GOSUB 1090
680 NEXT I
690 NEXT J
700
710
720 REM NOW WE PRINT
730 FOR J=1 TO N
740 LET Q=A(J)
750 REM P1 PICKS UP THE TERM SORTED ON.
760 ON P1 THEN 770,790,820,850
770 PRINT A$(J),
780 GO TO 900
790 REM
800 PRINT B$(J),
810 GO TO 900
820 REM
830 PRINT C(J,1),
840 GO TO 900
850 REM
860 PRINT C(J,2),
870 GO TO 900
880 STOP
890 REM WE NOW PRINT THE OTHER TERMS IN THE ENTRY THAT WERE REQUESTED.
900 FOR I=1 TO NUM
910 ON P(I) THEN 920,940,970,1000
920 PRINT A$(Q),
930 GO TO 1040
940 REM
950 PRINT B$(Q),
960 GO TO 1040
970 REM
980 PRINT C(Q,1),
990 GO TO 1040
1000 REM
1010 PRINT C(Q,2),
1020 GO TO 1040
1030 STOP
1040 NEXT I
1050 PRINT " "
1060 REM ON THE NEXT J WE GO AFTER THE SECOND ENTRY TO BE PRINTED,ETC.
1070 NEXT J
1080 STOP
1090 LET W=A(I)
1100 LET A(I)=A(I+1)
1110 LET A(I+1)=W
1120 RETURN
1130 DATA 7
1140 DATA ABRAHAM,LINCOLN,16,1865
1150 DATA GEORGE, WASHINGTON,1,1799
1160 DATA ANDREW, JACKSON, 7,1845
1170 DATA JOHN, KENNEDY,35, 1963
1180 DATA THEODORE, ROOSEVELT,26,1919
1190 DATA FRANKLIN, PIERCE,14,1869
1200 DATA JAMES, BUCHANAN,15,1868
1210 END