Sort Routine

Developer(s): Leo Morgan
Date: 1981
Type: Program
Platform(s): ZX81, TS 1000
Tags: Utility

Answer ENTER NUMBER OF WORDS with how many words you have, then type each word (1 to 20 characters). The program counts the entries and prints the list in alphabetical order.

RUN 200 saves the program as SORT and starts it again. It fits in 1K.

Published in Syntax October 1981 (Sort Routine).

Related Articles

This routine can sort 20 words of 20 characters in about 8 seconds.

Image Gallery

Source Code

   1 REM ALPHA-NUMERIC SORT ROUTINE REVISED BY LEO MORGAN 9/5/81
   5 PRINT "ENTER NUMBER OF WORDS, 1 TO N"
  10 INPUT N
  15 DIM A$(N,20)
  20 FOR I=1 TO N
  25 PRINT "TYPE A WORD, 1 TO 20 CHARACTERS"
  27 PRINT AT 21,0;I
  30 INPUT A$(I)
  35 CLS
  40 NEXT I
  50 LET X=0
  60 LET X=X+1
  70 IF X>N THEN STOP
  80 IF A$(X)="ZZZZZZZZZZZZZZZZZZZZ" THEN GOTO 60
  90 FOR Y=1 TO N
 100 IF A$(Y)<A$(X) THEN LET X=Y
 110 NEXT Y
 120 PRINT A$(X)
 130 LET A$(X)="ZZZZZZZZZZZZZZZZZZZZ"
 140 GOTO 50
 200 SAVE "SORT"
 210 GOTO 5

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.