There are probably better sorts around for the Nascom, but
either they are being kept a dark secret, or I have missed their
publication (not a difficult trick in Saudi Arabia), so I
decided to write my own. Being an ardent exponent of the art of
coarse programming, my code owes nothing to elegance and even
does a couple of naughties, hence the name, BruteSort.
I am not sure of the sorting jargon but I think it’s a
modified Shell-Shuffle-Shuttle sort (or have I just invented a
test of soberiety? Try saying that when you have had a few). The
logic of the thing was taken from a BASIC listing in a magazine
and there are probably more efficient algorithms around but I’ve
found it adequate for my needs. No! Lets be honest, it impresses
the hell out of me.
I’ll leave it to others to obtain accurate timings, but
going by the kitchen clock, BruteSort takes about 3 seconds to
sort a 1000 element array of random strings. This sorted array
can then be sorted into descending order in about 1.6 seconds
while it takes a dazzling 0.9 seconds to resort the array with
one element out of sequence. All these timings were on a machine
running at 4MHz.
The code sits at A000H and is 12BH bytes long, so remember
when initialising BASIC that ‘Memory Size ?’ must not exceed
There are several ways in which BruteSort can be used. Lets
take the following string as a typical example in the array
“25402088LOGS J LONDON SORTER ”
This string is a concatenation of four fields:
To sort the entire array by name (omitting the zeroeth element,
but BruteSort can handle it a you wish)...
...will do the trick provided that A does not evaluate to -1. If
it does then a descending sort will be returned.
Let’s say, for some unfathomable reason, we wish to sort