• Re: Sorting algorithms

    From Matthew Phillips@spam2011m@yahoo.co.uk to comp.sys.acorn.programmer on Wed Nov 25 20:05:38 2026
    From Newsgroup: comp.sys.acorn.programmer

    In message <5d3913ac38bob@sick-of-spam.invalid>
    on 17 Nov 2026 Bob Latham wrote:

    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.

    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.

    You might like to consider the SWI Territory_Collate which has options to ignore both case and accents. I see from RISC OS 5.22 onwards it can even interpret numbers in the string and sort them more naturally.

    It will probably slow things down a little as a SWI will always be slower
    than an optimised routine in assembly language.
    --
    Matthew Phillips
    Durham
    --- Synchronet 3.21e-Linux NewsLink 1.2
  • From Bob Latham@bob@sick-of-spam.invalid to comp.sys.acorn.programmer on Wed Nov 25 21:07:07 2026
    From Newsgroup: comp.sys.acorn.programmer

    In article <163f6e3d5d.Matthew@sinenomine.co.uk>,
    Matthew Phillips <spam2011m@yahoo.co.uk> wrote:

    You might like to consider the SWI Territory_Collate which has
    options to ignore both case and accents.

    That's interesting, thanks for that.

    Bob.

    --- Synchronet 3.21e-Linux NewsLink 1.2
  • From Jean-Michel@jmc.bruck@orange.fr to comp.sys.acorn.programmer on Thu Nov 26 12:50:27 2026
    From Newsgroup: comp.sys.acorn.programmer

    In message <5d3d73e064bob@sick-of-spam.invalid>
    Bob Latham <bob@sick-of-spam.invalid> wrote:

    In article <163f6e3d5d.Matthew@sinenomine.co.uk>,
    Matthew Phillips <spam2011m@yahoo.co.uk> wrote:

    You might like to consider the SWI Territory_Collate which has
    options to ignore both case and accents.

    That's interesting, thanks for that.

    Yes, but don't forget Céline is Canadian/French...


    Bob.
    --
    Jean-Michel
    --- Synchronet 3.21e-Linux NewsLink 1.2
  • From Harriet Bazley@harriet@bazleyfamily.co.uk to comp.sys.acorn.programmer on Thu Nov 26 22:32:43 2026
    From Newsgroup: comp.sys.acorn.programmer

    On 26 Nov 2026 as I do recall,
    Jean-Michel wrote:

    In message <5d3d73e064bob@sick-of-spam.invalid>
    Bob Latham <bob@sick-of-spam.invalid> wrote:

    In article <163f6e3d5d.Matthew@sinenomine.co.uk>,
    Matthew Phillips <spam2011m@yahoo.co.uk> wrote:

    You might like to consider the SWI Territory_Collate which has
    options to ignore both case and accents.

    That's interesting, thanks for that.

    Yes, but don't forget Céline is Canadian/French...

    I only have Territory 1 (UK) on this computer so can't use other
    territory numbers to test, but Territory_Collate certainly sorts Céline
    and Coline correctly for me...


    DIM block% 256

    DATA Céline,Celine,Celine1,Celia,Coline,XXX
    items%=0: name$=""
    WHILE name$<>"XXX"
    READ name$
    PRINT name$
    $(block%+items%*16)=name$+CHR$(0)
    items%+=1
    ENDWHILE

    items%-=1

    PRINT "Press space bar to repeat, or any other key to end"

    REPEAT
    str2%=RND(items%)-1
    SYS"Territory_Collate",-1,block%,block%+str2%*16,3 TO result%
    PRINT result%
    CASE TRUE OF
    WHEN result%>0:outcome$="greater than"
    WHEN result%=0:outcome$="equal to"
    WHEN result%<0:outcome$="less than"
    ENDCASE
    PRINT $block%;" is ";outcome$;" ";$(block%+str2%*16)
    UNTIL GET<>32
    --
    Harriet Bazley == Loyaulte me lie ==

    ObChocolate: Nice!
    --- Synchronet 3.21e-Linux NewsLink 1.2
  • From Martin@News04@avisoft.f9.co.uk to comp.sys.acorn.programmer on Thu Nov 26 23:16:42 2026
    From Newsgroup: comp.sys.acorn.programmer

    In article <7d8cff3d5d.harriet@bazleyfamily.co.uk>,
    Harriet Bazley <harriet@bazleyfamily.co.uk> wrote:
    On 26 Nov 2026 as I do recall,
    Jean-Michel wrote:

    In message <5d3d73e064bob@sick-of-spam.invalid>
    Bob Latham <bob@sick-of-spam.invalid> wrote:

    In article <163f6e3d5d.Matthew@sinenomine.co.uk>,
    Matthew Phillips <spam2011m@yahoo.co.uk> wrote:

    You might like to consider the SWI Territory_Collate which has
    options to ignore both case and accents.

    That's interesting, thanks for that.

    Yes, but don't forget Céline is Canadian/French...

    [Snip]

    $(block%+items%*16)=name$+CHR$(0)

    That illustrates one of the problems with using Territory_Collate - it
    needs zero terminated strings, but BASIC strings are cr terminated,
    or have a length and no terminator. So each string needs a zero adding
    before the collate - probably requiring a copy of the string, and
    removing the null afterwards. For small numbers of strings that is not
    a problem, but with thousands of strings it will be an overhead of
    both time and memory.
    --
    Martin Avison
    Note that unfortunately this email address will become invalid
    without notice if (when) any spam is received.
    --- Synchronet 3.21e-Linux NewsLink 1.2