🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.acorn.programmer
Article #23

Re: Sorting algorithms

#23
From: Bob Latham
Date: Tue, 17 Nov 2026 09:11
70 lines
3466 bytes
In article <5d38c72b71Paul@sprie.nl>,
   Paul Sprangers <Paul@sprie.nl> wrote:

> A string is 'bigger' than another if it alphabetically comes after
> the other one. "Sebastian Barthel" is bigger than "Sebestian Bach"!

> The point is that BASIC only looks at the ASCII value of characters
> for determining the alphabetical flow. Therefore it puts 'Céline'
> after 'Coline', for example.

> The other point was that OP's original routine takes 12.7 seconds
> to sort a list of over 4000 lines and still has the 'Céline'
> problem, while a simple BASIC program (okay, compiled) sorts 6000
> lines without that problem in about 3 seconds.

> But of course, this simple program can be enhanced a lot further in
> many ways, one of which is sorting pointers rather than strings, as
> you already pointed out.

Sorry guys, I've been unwell for a few days so updates.

I've got the sort time down to 5 seconds and this includes a 'Céline'
fix.

It's crude yes but it works and it's quite fast. I repeatedly scan
scan though the file and each pass copy the bets lie to another file
and of course I mark the line as invalid in the first file.
Eventually, a scan finds nothing left and we're done.

The room for the second file comes from an expanded wimp slot which
is reduced back agin when the sort is complete.

For my 'Céline' fix i noticed that the possible problem characters
are for the most part form &C0 upwards and so I simply have a
substitution table for those chars which is only used in the
comparison section, I don't actually change the characters.

I don't know if I can add a little code here but here is the core of
my sort routine ...

            ADR R4,treat_as-&C0 

 .BSFLpx23  CMP R10,R11
            BCS BCSLpx88;     end of file

            LDRB R0,[R6],#1;    BSF
            LDRB R0,[R0,R12];   convert to lower case
            CMP R0,#&C0
            LDRCSB R0,[R0,R4]

            LDRB R3,[R8],#1;    New Challenger
            LDRB R3,[R3,R12];   convert to lower case
            CMP R3,#&C0
            LDRCSB R3,[R3,R4]

            CMP R3,R0;          new,bsf
            BEQ BSFLpx23
            STRCC R10,bestSOFAR
;------------


 .treat_as  EQUS"AAAAAAÆCEEEEIIII"
            EQUS"DNOOOOOרUUUUYÞß"
            EQUS"aaaaaaæceeeeiiii"
            EQUS"onooooo÷øuuuuyþÿ":ALIGN
  
Thanks everyone.

Bob.
Technical Details
Message-ID: <5d3913ac38bob@sick-of-spam.invalid>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!news.tcpreset.net!newsfeed.bofh.team!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
References: <5d336712aebob@sick-of-spam.invalid> <5d3622ac84Paul@sprie.nl> <5d3628e1b7News04@avisoft.f9.co.uk> <5d362f6206Paul@sprie.nl> <11dfi5o$1l3bi$1@solani.org> <5d38c72b71Paul@sprie.nl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!news.tcpreset.net!newsfeed.bofh.team!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: Bob Latham <bob@sick-of-spam.invalid>
Newsgroups: comp.sys.acorn.programmer
Subject: Re: Sorting algorithms
Date: Tue, 17 Nov 2026 09:11:31 +0000 (GMT)
Organization: None
Lines: 70
Message-ID: <5d3913ac38bob@sick-of-spam.invalid>
References: <5d336712aebob@sick-of-spam.invalid> <5d3622ac84Paul@sprie.nl>
	<5d3628e1b7News04@avisoft.f9.co.uk> <5d362f6206Paul@sprie.nl> <11dfi5o$1l3bi$1@solani.org> <5d38c72b71Paul@sprie.nl>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: individual.net UQpwwKO3Mcqfejbc0mrshQ2yy8+WF0VjIB3v6nRz0oTxunBkeS
X-Orig-Path: sick-of-spam.invalid!bob
Cancel-Lock: sha1:Ro/BUWb/VdXpE+blqZBtaD8dNuM= sha256:UpMTKwbYn1b9Fc5t7CkD0Dz9mkpfdcCx4cvu7HpAGiI=
X-No-Archive: Yes
User-Agent: NewsHound/v1.54