SORTING TEXT and a Text Viewer by B. Cain There are two types of routines for sorting text into alphabetical order and they are referred to by the names BUBBLE SORT and SHELL SORT. The first is kind of slow but is used when regular sorting takes place and there is no need for large volume sorting, or in other words only the most recent text input is sorted. In theory this can be actually faster because it is sorting only small amounts of text at any one time. The SHELL SORT routine is much faster for large chunks of data but I haven't come across an Amos version yet ( I live a sheltered life y'know), but I digress, this kind of sort was tailor made for large volume sorting and is used where the bubble sort would make you cry with impatience. However, I recently came across a SHELL SORT routine in AmigaBASIC which really impressed me, I mean it sorted words at the rate of 200 in about 1.5 seconds,yes that's right, now at this point if you are muttering things to yourself like "so what!" and "where's this person been all this time!" or "doesn't he know of such and such a routine which is twice as fast!" then the answer is no I don't, and if you are muttering these things, then you do have a faster SHELL SORT, I want it, so please be kind and send it to Amoszine so we can all benefit, but if as I suspect you haven't got any such thing and you are still interested then read on. When I say 200 words in 1.5 seconds, this is only an observation and I think the actual process needs to be timed accurately and with more data, I was intending to type in more than 200 words but I got fed up after typing in these first 200 words, so if you are curious you can type in the next 200 words and tell us all about it sometime. This sorting was done on a humble A500 with half a meg of Fast Ram with not an accelerator in sight. Do you lucky A1200 owners out there realise this routine would in theory sort words 3 times faster on your machines?, and when compiled the speed would be even greater I think, but I haven't compiled it yet so I couldn't be sure about this. Now stop talking at the back there 'cos I am about to say something important, ( who said "about time!"? ). Well this routine is on this issue and goes under the name of SORTED_TEXT.AMOS together with a Random Access file called UNSORTED_FILE which contains 200 words in random order. Like I said earlier you can easily add more words to this file as long as each word is not more than 20 letters long. If you're not sure how to do this then use the routine below. R$="RAM:UNSORTED_FILE" : D$="UNSORTED_FILE" Open in 1,D$ D=lof(1) Close 1 ' Erase 10 : Rem Now load into RAM for speedy input Reserve as Work 10,D Bload D$,Start(10) Bsave R$,Start(10) to Start(10)+D ' Rem Now we input 100 more words into the file in RAM Open Random 1,R$ Field 1,20 As WORD$ For A=201 to 400 Input "Enter word ";WORD$ Put 1,A Next A Close 1 ' Open in 1,R$ : Rem Now get new size of file D=lof(1) Close 1 ' Erase 10 : Rem Now load into RAM and save to disk Reserve as Work 10,D Bload R$,Start(10) Bsave D$,Start(10) to Start(10)+D You don't need me to tell you the programs to which this sort routine could be applied and there must be quite a few which would benefit. Numbers can also be sorted but must be in string format together with one or two other caveats which are explained in the source code. I am leaving it to all you coders now to use this routine as you see fit, but please write to Amoszine and tell us how it made or buggered up your proggie.... I bet you thought I was never going to get around to the Text Viewer bit, but it's going to be something in the style of PPmore. I haven't finished it yet but it is coming along nicely and I will be sharing the source code with you as soon as I think it's good enough. By the way I'm not sure yet how I could get it to load and display crunched text without infringing on somebody's copyright. Any suggestions and hints would be welcome so please write in if you feel you could help.....cheers. -- Bernie