Bubble not handling Swedish letters Å, Ä and Ö correctly

Hi!
I’m working with data that contains the Swedish letters “Å”, “Ä” and “Ö” which are chronologically after “Z” in the alphabet.

However, Bubble.io seems to handle Å → A, Ä → A and Ö → O. This becomes a problem when I want to sort by a data field that has these records that begin with these letters.

How do I get Bubble.io to treat Å, Ä and Ö correctly? I guess this is an encoding problem?

Thanks in advance,
Isak

1 Like

I first experienced this 3 years ago…likely will never be fixed

Hejsan Isak! :slight_smile:

There actually is a way to make sorting using the correct alphabetical order (collation) with glyphs such as ÅÄÖ. The “problem” is that you have to define the sorting yourself and then use that definition when you retrieve the data.

I guess the advantage is that you can sort however you like, depending on your locale and language, but one could argue that Bubble should have made this built-in.

Here’s how I would do it:

  1. In the Data type you wish to sort, add a field like “Name Sorting Order” for each thing you want to sort on, as type “number” and with a default of “0” (zero) which means no specific sorting needed.

  2. Create a database trigger that reacts any time there is a change (ie: it’s new, or updated) to the field of the data type you want to sort on:

  3. In the trigger workflow, add a “sorting order” number for when the character that isn’t sorting properly (ie: Å, Ä, Ö) is found in the data entered:


(in this case, I use a regex to extract the first character after having uppercased the data)

  1. Lastly, when listing the data, make sure to first sort on the Sorting Number, and only after that the data itself second:

Now, the list appears in the order you expected:

Note to all reading this:

  • This example is very simplified and assumes you sort on the first character only. The sorting “regex” and resulting sort number can be made (much) more advanced to handle other sorting issues such as looking at the following character (ie to handle French sorting rules for diacritics such as “rôle” before “rose”).

  • If one wants to disregard prefixes like “The” or “St.” in sorting, a similar approach can be used by cropping out these prefixes and setting up a sorting column that instead holds the essence (“Shining” instead of “The Shining” or “Claire” instead of “St. Claire”) and sorting on that field, while displaying the full text.

  • I use a Database Trigger to do this instead of of handling it in the “Create a new…” workflow because to me it’s safer to handle it in one place, over having to remember to implement this in every place where you may be adding or updating the data. Feel free to do it differently if you like to live dangerously.

Lycka till :slight_smile:

1 Like

Thanks a lot Alexander, highly appreciated the detail in your answer. I’ll copy your solution :slightly_smiling_face:

Ha det fint!

1 Like