Ordering alphabetically

Discuss all aspects of programming here. From 8-bit through to modern architectures.
User avatar
richmond62
Posts: 170
Joined: Sun Apr 16, 2017 3:15 pm

Ordering alphabetically

Postby richmond62 » Mon Jun 26, 2017 3:33 pm

While I can do this sort of thing:

Code: Select all

10 A$="zxf"
20 B$="acd"
30 IF A$<B$ THEN PRINT "I'M A LITTLE TEAPOT"


what is not clear to me is what the "<" is referring to:

the first character in a string, or some odd sum derived from the string's component characters.

I should like to alphabeticise a list stored in an array and any help
would be great.

User avatar
hoglet
Posts: 6620
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol

Re: Ordering alphabetically

Postby hoglet » Mon Jun 26, 2017 3:57 pm

See this section of the User Guide for the definition of string comparison:
http://bbc.nvg.org/doc/BBCUserGuide-1.00.pdf#page=130

Dave

User avatar
richmond62
Posts: 170
Joined: Sun Apr 16, 2017 3:15 pm

Re: Ordering alphabetically

Postby richmond62 » Mon Jun 26, 2017 4:00 pm

Thanks, Dave

Had I been in my right mind, instead of dog tired after a day's work that might have occurred to me :D

User avatar
danielj
Posts: 5345
Joined: Thu Oct 02, 2008 4:51 pm
Location: Manchester

Re: Ordering alphabetically

Postby danielj » Mon Jun 26, 2017 4:19 pm

Alphasort on the BBC Welcome disc/tape should have the routines you're looking for?
I seem to recall it implements a number of different algorithms.

User avatar
richmond62
Posts: 170
Joined: Sun Apr 16, 2017 3:15 pm

Re: Ordering alphabetically

Postby richmond62 » Mon Jun 26, 2017 5:53 pm

Alphasort probably does . . . BUT:

1. I have a number of small children who have been given a colon-delimited string of names:

"ZANDER:ANNIE:JACK:CALUM:NICOL:SHOLTO:CATRIONA:RENTON"

which they have to "chop up", bung into an array, sort,
and print to screen a list of the names in alphabetical
order

using the BASIC that is "there" on the BBC Micro.

Bog-standard Bubble sort :D

User avatar
danielj
Posts: 5345
Joined: Thu Oct 02, 2008 4:51 pm
Location: Manchester

Re: Ordering alphabetically

Postby danielj » Mon Jun 26, 2017 6:54 pm

I think I misunderstood what you were after there :D - just clarity on what the comparator was doing?

d.

User avatar
richmond62
Posts: 170
Joined: Sun Apr 16, 2017 3:15 pm

Re: Ordering alphabetically

Postby richmond62 » Mon Jun 26, 2017 7:05 pm

what the comparator was doing

Well, whether that was my "goofiness" in not expressing myself, or . . .

we did get a bit lost.

The problem, if it is a problem (and I'd like to think it is NOT), is that
children ask WHY . . . and I suppose I'm just going to have to print
out an ASCII chart and then start getting jazzy about Unicode

[Oh, and by the way, Unicode standard version 10 has just been released,
which is very exciting indeed:

http://blog.unicode.org/2017/06/announc ... n-100.html]

User avatar
flaxcottage
Posts: 2797
Joined: Thu Dec 13, 2012 8:46 pm
Location: Derbyshire

Re: Ordering alphabetically

Postby flaxcottage » Mon Jun 26, 2017 7:15 pm

It is easy to explain if the names all start with a different letter. :D

Sort Anna and then Anne becomes harder. The ">" sign or the "<" sign (depending on your sort algorithm) compare each letter in turn until the inequality triggers, which it will do with the last letter in this case. Young childers can understand that.

Then try explain the order 1, 10, 11, 12, 2, 3, ... 8, 9 if trying to sort numeric strings 1 - 12 in BBC BASIC without going into ASCII :? :lol: !
- John

Currently running Level 4 Econet with BBC B, BBC B+ 128K, Master 128K, 4Mb A3000, 4Mb A3020, 4Mb A4000, 4Mb A5000 dual FDD; UK101; HP41CX setup; Psion 3a, 3mx and 5mx; Z88; TI-58c, TI-59 and printer, HP-16C programmer's calculator

User avatar
richmond62
Posts: 170
Joined: Sun Apr 16, 2017 3:15 pm

Re: Ordering alphabetically

Postby richmond62 » Mon Jun 26, 2017 7:24 pm

Young childers can understand that.

Wow: my wife is currently writing a book on Historical Linguistics and the development of English. She can get a bit pompous
when she is "slaving over the hot computer" so I like to annoy her a spot.

I was asking her whether she believed that the Southern dialectal plurals for child and brother (i.e. NOT children and brethren)
were still in use: childer and brether.

You have made my day: Thanks so much.

User avatar
leenew
Posts: 3402
Joined: Wed Jul 04, 2012 3:27 pm
Location: Doncaster, Yorkshire

Re: Ordering alphabetically

Postby leenew » Mon Jun 26, 2017 7:32 pm

Oooh! I bet she has this book then:

51PtXjIfaUL._SX324_BO1,204,203,200_.jpg

https://www.amazon.co.uk/d/Books/Mother ... her+tongue
Just read it on holiday and thoroughly enjoyed it.

Lee.

User avatar
richmond62
Posts: 170
Joined: Sun Apr 16, 2017 3:15 pm

Re: Ordering alphabetically

Postby richmond62 » Mon Jun 26, 2017 7:36 pm

bet she has this book

She does; although, as she is a Prof. at a Uni' she is writing something far more detailed.

I'm having to do all the maps and charts of vowel changes and so on :)

Personally I preferred Melvyn Bragg's book (and the TV series):

https://en.wikipedia.org/wiki/The_Adventure_of_English

User avatar
leenew
Posts: 3402
Joined: Wed Jul 04, 2012 3:27 pm
Location: Doncaster, Yorkshire

Re: Ordering alphabetically

Postby leenew » Mon Jun 26, 2017 7:46 pm

Thanks for that, I haven't heard of it before :D
Sorry to drag the thread off topic, so back to the sorting :wink:

Lee.

User avatar
richmond62
Posts: 170
Joined: Sun Apr 16, 2017 3:15 pm

Re: Ordering alphabetically

Postby richmond62 » Mon Jun 26, 2017 7:59 pm

Sorry to drag the thread off topic

It's "drags" like that that make life pleasurable. :D

And I think that the sorting has already been sorted out!

User avatar
leenew
Posts: 3402
Joined: Wed Jul 04, 2012 3:27 pm
Location: Doncaster, Yorkshire

Re: Ordering alphabetically

Postby leenew » Mon Jun 26, 2017 8:06 pm

Ah cool 8)

(The ironic thing is that in my last post I used "haven't" when I probably should have used "hadn't") :roll:

Lee.

User avatar
richmond62
Posts: 170
Joined: Sun Apr 16, 2017 3:15 pm

Re: Ordering alphabetically

Postby richmond62 » Sun Jul 02, 2017 7:56 am

You can watch Melvyn Barge (as they used to call him on Spitting Image) strut his funky
stuff in The Adventure of English on YouTube:

https://youtu.be/K1XQx9pGGd0?list=PLbBv ... hMHSyq-lhe

Very soothing, even if he does tend to skip the difficult bits.


Return to “programming”

Who is online

Users browsing this forum: No registered users and 1 guest