Alphabeticising a word list?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10248
Joined: Fri Feb 19, 2010 10:17 am

Alphabeticising a word list?

Post by richmond62 » Fri Nov 21, 2025 9:03 am

I have an alphabet (and it really doesn't matter which one it is) that is NOT the English variant of the Latin alphabet (let's call it Ruritanian).

Now I have a load of Ruritanian texts that have been entered into a textField in Unicode-compliant Ruritanian script . . .

Now I want to take each word out of that textField (and, before you ask, word breaks are SPACES) and shove it in a listField, and then . . .

ALPHABETICISE
that list according to the alphabetical order of the Ruritanian alphabet.

Obviously SORT will NOT do that.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10248
Joined: Fri Feb 19, 2010 10:17 am

Re: Alphabeticising a word list?

Post by richmond62 » Fri Nov 21, 2025 9:09 am

Should this work?

Code: Select all

sort lines of test by customSort(richmondsOrder,each)
The problem is apparently, that richmondsOrder might prove a bit awkward as I am not convinced that:

Code: Select all

put numToCodePoint(2296) & numToCodePoint(2297) & numToCodePoint(2298) into richmondsOrder
is going to "sit nicely".

Klaus
Posts: 14270
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Alphabeticising a word list?

Post by Klaus » Fri Nov 21, 2025 12:41 pm

Please post your function "customSort"!

Maybe take a look at this:
https://lessons.livecode.com/m/2592/l/1 ... ing-a-list
8)

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10411
Joined: Wed May 06, 2009 2:28 pm

Re: Alphabeticising a word list?

Post by dunbarx » Fri Nov 21, 2025 2:54 pm

Richmond.

Klaus implied what you already said, that is, you have to explicitly specify the "order" of "letters" of your alphabet. Then you can create a list of such letters that are paired with a number. Once you have that, then a custom function can sort it.

If this Martian alphabet is entirely your own, then no existing "codePoint" can help.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10411
Joined: Wed May 06, 2009 2:28 pm

Re: Alphabeticising a word list?

Post by dunbarx » Fri Nov 21, 2025 3:17 pm

Maybe I misread.

Your alphabet is unicode-based? If so, what is the issue? Is the codePoint order of that alphabet not, er, ordered?

Craig

SparkOut
Posts: 2969
Joined: Sun Sep 23, 2007 4:58 pm

Re: Alphabeticising a word list?

Post by SparkOut » Fri Nov 21, 2025 4:19 pm

It may be as simple as "sort international" but I that is a hope, rather than expectation.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10411
Joined: Wed May 06, 2009 2:28 pm

Re: Alphabeticising a word list?

Post by dunbarx » Fri Nov 21, 2025 5:03 pm

Sparkout.

It sounds like the alphabet is Elbonian. I do not think they follow ordinary conventions.

Craig

Klaus
Posts: 14270
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Alphabeticising a word list?

Post by Klaus » Fri Nov 21, 2025 5:12 pm

I also exspected something "highly exotic", but looks like this is just a sort of custom font:
http://www.myfont.de/fonts/charmap/2275-Ruritania.html
:D

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10411
Joined: Wed May 06, 2009 2:28 pm

Re: Alphabeticising a word list?

Post by dunbarx » Fri Nov 21, 2025 6:09 pm

Hmmm. I see it.

Richmond, what is your issue?

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10248
Joined: Fri Feb 19, 2010 10:17 am

Re: Alphabeticising a word list?

Post by richmond62 » Fri Nov 21, 2025 7:56 pm

If this Martian alphabet is entirely your own, then no existing "codePoint" can help.
No Martian alphabets will get hurt in this exercise, but I could have listed:

Devanagari
Grantha
Bengali
Old Bulgarian Cyrillic
Glagolitic
Gothic
Old Norse
Anglo-Saxon
Ge'ez Amharic

But was attempting some sort of shorthand by using 'Ruritanian'.

SparkOut
Posts: 2969
Joined: Sun Sep 23, 2007 4:58 pm

Re: Alphabeticising a word list?

Post by SparkOut » Fri Nov 21, 2025 8:28 pm

richmond62 wrote:
Fri Nov 21, 2025 9:09 am
Should this work?

Code: Select all

sort lines of test by customSort(richmondsOrder,each)
The problem is apparently, that richmondsOrder might prove a bit awkward as I am not convinced that:

Code: Select all

put numToCodePoint(2296) & numToCodePoint(2297) & numToCodePoint(2298) into richmondsOrder
is going to "sit nicely".
That indeed will not "sit nicely".

I think either never mind the custom sort, unless there's something you need to adjust that an international sort won't chew. Or work your custom sort into a function, then call it

Code: Select all

sort lines of test by richmondsOrder(each)
and you'd define a function,

Code: Select all

function richmondsOrder pData
which takes each iteration of the source data element and return "something" as a sorting index for the original sort to work on.

stam
Posts: 3147
Joined: Sun Jun 04, 2006 9:39 pm

Re: Alphabeticising a word list?

Post by stam » Fri Nov 21, 2025 9:01 pm

I'd offer an opinion but I can't say I'm certain I understand what Richmond's ask actually is?
Sort the words?
Sort the words by more than the first char?
Sort the letters within each word?
Sort all the letters of the text into char-soup?

The question that immediately follows is why. Not being facetious, but presumably this is aid of loftier goal, that may be more effectively achieved using other means.

Perhaps if Richmond can expand what he's trying to do and what exactly he wants it might be easier to offer help...

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10411
Joined: Wed May 06, 2009 2:28 pm

Re: Alphabeticising a word list?

Post by dunbarx » Fri Nov 21, 2025 9:07 pm

Richmond.

So Ruritania is an imaginary world derived from three novels starting with "The Prisoner of Zenda".

This means the alphabet does not really exist.

But there is a published imaginary alphabet. Why not simply attach a number to each Rumanian letter, sort those pairs numeric and then strip the numbers?

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10411
Joined: Wed May 06, 2009 2:28 pm

Re: Alphabeticising a word list?

Post by dunbarx » Fri Nov 21, 2025 9:13 pm

Hey, there is a Ruritainium font, and unicode contains it. For example, "A" is U+0041.

Done. You can sort away.

Craig

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4197
Joined: Sun Jan 07, 2007 9:12 pm

Re: Alphabeticising a word list?

Post by bn » Fri Nov 21, 2025 10:02 pm

Richmond,

from the dictionary entry for sort container:
Name: sortType
Type: enum
Description:
If you don't specify a sortType, the sortType is text.

• international: sorts by collation according to the system locale
• numeric: sorts by number. (Use this form if the sortKey consists of numbers)
• datetime: treats the sortKey as a date and/or time
text: sorts using a codepoint by codepoint comparison
• binary: sorts using a byte by byte comparison

So I gave it a try:
sortDevanagari.livecode.zip
(3.32 KiB) Downloaded 19 times

No idea what it is saying or if it is working or not. It does sort however.

Kind regards
Bernd

Post Reply