EFFORTLESS INDEX (1K ZX81)
by L Basford, Crewe, Cheshire
from Your Computer, January 1982, Page 61

A succession of words or phrases as long as the RAM can accommodate is
entered in any order, the program is run and, hey presto - the entries are
printed in a strictly alphabetical sequence.

With 16K of RAM it is feasible to index several issues of Your Computer or
to assemble a personal telephone directory or catalogue in detail a
collection of gramophone records.

As printed here the program has been stripped down to its bare essentials to
fit the unexpanded ZX-81. In this form, it will accept a maximum of 19 words
of 10 characters; this is a convenient number since the result can be
displayed down the screen without having to invoke Cont.

Of course, it is not restricted to words of 10 characters: the string length
can be adjusted simply by changing the appropriate figure in line 30; but
without extra memory one has to opt for either a greater number of shorter
words or a smaller number of longer words.

The program is very straightforward and loads easily. It consists of a
two-dimensional string array whose contents are inspected in lines 65-75: if
any two adjacent entries are out of alphabetical order they are transposed
by the subroutine of lines 85-95. A subsequent inspection - lines 105-115 -
checks that each entry is by now occupying its proper place in the sequence.

Because it needs to initialise an array, the computer will ask at the outset
how many words it is to receive. As soon as it has been given the answer by
inputting X, the string-input cursor, L, appears and the entries can then be
typed in with each one followed as usual by Newline.

After the final Newline there is a blank-screen interlude - hardly
noticeable unless X is large - before the alphabetical list automatically
appears on the screen.
