Alphabeticising a word list?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: Alphabeticising a word list?
I suspect that it's going to be something Richmond is trying to generalise for multiple alphabets.
sort international might work for many situations but it uses the system locale
I dare say his system locale is set for a western alphabet, but given that he works with a variety of other writing systems, that isn't necessarily going to be applicable when changing between them in terms of keyboard input and field display.
So *maybe* that's the problem. Maybe there's a solution. I don't even know if (eg) Devanagari has an ordered alphabet.
I guess it must if Richmond is seeking to alphabetically sort it.
sort international might work for many situations but it uses the system locale
I dare say his system locale is set for a western alphabet, but given that he works with a variety of other writing systems, that isn't necessarily going to be applicable when changing between them in terms of keyboard input and field display.
So *maybe* that's the problem. Maybe there's a solution. I don't even know if (eg) Devanagari has an ordered alphabet.
I guess it must if Richmond is seeking to alphabetically sort it.
Re: Alphabeticising a word list?
Devanagari was just an example. The point I was trying to make is that it says that "text" type of sort (implicitely the default) sorts
Maybe a simple sort is enough? But what do I know about higher planes of unicode.• text: sorts using a codepoint by codepoint comparison
Kind regards
Bernd
-
scott_morrow
- VIP Livecode Opensource Backer

- Posts: 41
- Joined: Tue Jun 27, 2006 8:35 pm
- Contact:
Re: Alphabeticising a word list?
I'm not entirely certain what Richmond is after but long ago (in SuperCard) before I understood that there was a sort() function, I wrote an alphabetizing handler that worked out the order for any list of arbitrarily long words. It was a short exercise (the long exercise was finding the code from nearly 30 years ago) to add the ability to sort a *custom* alphabet. (It expects to be given text that has one word per line, which I don't believe is what the OP suggested. I will leave chunking out words as an exercise for the reader.) It does require knowing the relative sort order of each char but will work in odd situations like mixing characters from different languages or even using emojis as numbers and letters. WHY anyone would want to do this is the answer to a different question.
- Attachments
-
- Alphabetize.livecode.zip
- (6.05 KiB) Downloaded 12 times
Elementary Software
...now with 20% less chalk dust!
...now with 20% less chalk dust!
-
richmond62
- Livecode Opensource Backer

- Posts: 10246
- Joined: Fri Feb 19, 2010 10:17 am
Re: Alphabeticising a word list?
Thank you very much: I shall give it a 'whirl' shortly.
-
richmond62
- Livecode Opensource Backer

- Posts: 10246
- Joined: Fri Feb 19, 2010 10:17 am
Re: Alphabeticising a word list?
Code: Select all
on mouseUp
sort lines of field 2 ascending text
end mouseUp
on mouseUp
put field 2 into tText
sort tText
put tText into field 2
end mouseUp
Yes, it does sort the words into some order that is NOT the order of the Devanagari abugida.
-
richmond62
- Livecode Opensource Backer

- Posts: 10246
- Joined: Fri Feb 19, 2010 10:17 am
Re: Alphabeticising a word list?
I worked out a comparatively sensible way of doing this without using 'sort' at all and have posted it elsewhere.
Re: Alphabeticising a word list?
OK… but why not post here as well to complete the question you raised here?richmond62 wrote: ↑Sun Nov 23, 2025 4:00 pmI worked out a comparatively sensible way of doing this without using 'sort' at all and have posted it elsewhere.
-
richmond62
- Livecode Opensource Backer

- Posts: 10246
- Joined: Fri Feb 19, 2010 10:17 am
Re: Alphabeticising a word list?
Because the solution was sui generis.
Re: Alphabeticising a word list?
A unique, non-generalisable sorting algorithm?????
And you thought that others may not benefit from this - because I guess no one has the ability extrapolate to from your unique invention to other situations…
Because we only post generalisable code here of course… right, gotcha…
This is genuinely the last time I’ll ever respond to a post of yours Richmond.
And you thought that others may not benefit from this - because I guess no one has the ability extrapolate to from your unique invention to other situations…
Because we only post generalisable code here of course… right, gotcha…
This is genuinely the last time I’ll ever respond to a post of yours Richmond.
-
richmond62
- Livecode Opensource Backer

- Posts: 10246
- Joined: Fri Feb 19, 2010 10:17 am
Re: Alphabeticising a word list?
Probably not: but what I worked out in the bath.A unique, non-generalisable sorting algorithm?????
- Attachments
-
- OBG sorter.livecode.zip
- Stack.
- (1.91 KiB) Downloaded 5 times
Re: Alphabeticising a word list?
Richmond.
I rarely see how you approach things. And has this topic morphed into something entirely different?
Anyway, I think I see what you are doing, that is, based on the line ordering of letters in fld "ordure"(I do like how you named that) you are sorting the words in a field of text according that order. But know this needs work. If you change the starting text to "Now is time the for all good men", the two special "T" words are not themselves sorted, but rather appear in the order of the baseline text, which is wrong.
Craig
I rarely see how you approach things. And has this topic morphed into something entirely different?
Anyway, I think I see what you are doing, that is, based on the line ordering of letters in fld "ordure"(I do like how you named that) you are sorting the words in a field of text according that order. But know this needs work. If you change the starting text to "Now is time the for all good men", the two special "T" words are not themselves sorted, but rather appear in the order of the baseline text, which is wrong.
Craig
-
richmond62
- Livecode Opensource Backer

- Posts: 10246
- Joined: Fri Feb 19, 2010 10:17 am
Re: Alphabeticising a word list?
Indeed: you are correct.the two special "T" words are not themselves sorted
Re: Alphabeticising a word list?
Richmond.
Here is a stack that does (I think) what you want, but with a readable script.
And anyway I disliked having to rely on double space as a delimiter, since that way lies madness).
The controlling order of chars ("ST" and then the rest of the alphabet), as per your post (currently "STABCDE...") can be anything if you adjust the contents of fld "Sort Key".
So much fun.
Craig
Here is a stack that does (I think) what you want, but with a readable script.
And anyway I disliked having to rely on double space as a delimiter, since that way lies madness).
The controlling order of chars ("ST" and then the rest of the alphabet), as per your post (currently "STABCDE...") can be anything if you adjust the contents of fld "Sort Key".
So much fun.
Craig
-
richmond62
- Livecode Opensource Backer

- Posts: 10246
- Joined: Fri Feb 19, 2010 10:17 am
Re: Alphabeticising a word list?
That is very clever, Thank you.
But:
- -
What I do NOT understand is when I insert a sort key 'YD' words starting with D are listed before words starting with Y.
Aha: I understand what the problem is:
- -
When I enter 'TS' I get what I get with 'ST' so it is still imposing English alphabetical order.
That is problematic BOTH for:
1. Sorting English language words in a non-standard order,
and:
- -
2. For another alphabet [this one is the Old Bulgarian alphabet]; especially as those letters (occurring in both Upper and Lower case forms) do NOT appear sequentially in Unicode.
So, to restate what I am aiming at:
A way to take a list of word in any alphabetic writing system and sort that list in that alphabetic writing system's order.
This does seem to be a tougher call than I had expected.
But:
- -
What I do NOT understand is when I insert a sort key 'YD' words starting with D are listed before words starting with Y.
Aha: I understand what the problem is:
- -
When I enter 'TS' I get what I get with 'ST' so it is still imposing English alphabetical order.
That is problematic BOTH for:
1. Sorting English language words in a non-standard order,
and:
- -
2. For another alphabet [this one is the Old Bulgarian alphabet]; especially as those letters (occurring in both Upper and Lower case forms) do NOT appear sequentially in Unicode.
So, to restate what I am aiming at:
A way to take a list of word in any alphabetic writing system and sort that list in that alphabetic writing system's order.
This does seem to be a tougher call than I had expected.
-
richmond62
- Livecode Opensource Backer

- Posts: 10246
- Joined: Fri Feb 19, 2010 10:17 am
Re: Alphabeticising a word list?
I suspect that after I have recovered from a rather nasty bout of 'flu I will return to my stack and try some sort of cyclical stuff to reorder words that start with the same letter also according to my list.