Subject |
Re: unconventional index |
From |
Tim Ward <tim@goldengrovenurserydotcodotuk> |
Date |
Mon, 11 Dec 2023 23:28:27 +0000 |
Newsgroups |
dbase.getting-started |
On 11/12/2023 22:03, Charlie wrote:
> I don't know if this is possible but is it possible to alter an alphabetical order using an index of some kind??
>
> Example being instead of having a table indexed alphabetically, like ABCDEF. Somehow alter the order like ACBDFE?
>
> Thanks for any comments.
>
>
Hi Charlie,
It should be possible, but it depends if it's worth it and why you need
to do it.
If you maintain a 'sort' field based on the order you want, you could
then use an index to sort on this maintained field.
So for example if you want vowels to be in a custom order, for example
u's sort after e but before i, you could write some code to maintain a
custom field. So in the custom sort field you would store
TextField CustomSortField
Fall Fall
Fell Fell
Fill Foll
Foll Full
Full Fill
Sorting on Customsortfield gives
TextField CustomSortField
Fall Fall
Fell Fell
Full Fill
Fill Foll
Foll Full
now with the desired sort order in TextField with u coming after e and
before i.
It's going to get complicated depending on how wonky you want the custom
sort order to be. Every time you change or add something to your main
field you will need to have code that updates the custom sort field.
I'm sure there's a more elegant way but this is how I tackled it when I
needed to display a custom font for graphics (like wingdings) but the
sort order I wanted wasn't a formal alphabetical order. That was easier
though as I only had a field 1 character wide.
Tim
|
|