-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support case-insensitive string sorting #2970
Comments
That's not currently possible, but I've updated this ticket to track adding that functionality. In the meantime, you could store a case-normalized version of the property you want to sort on in your model and sort on that. |
thank you |
What comparator is realm using when sorting strings? Let's assume, I have several objects that have the following value for the property name:
When I sort these values, using realm, the order will be the following:
I do understand that the uppercase names will always be placed after their lowercase equivalent. That makes sense since the sorting is case sensitive. However, I do not understand why |hello" and ~hello are sorted to the beginning and why éllo is not placed at the very bottom. I would expect that since this would be the order of their respective unicode codes. |
@tschubotz Realm has limited Unicode awareness when sorting strings, which is to say that all strings are sorted according to an We are aware that this is lacking for a wide range of use cases, but a proper solution to string sorting (including case-insensitivity) requires quite sophisticated locale support, which is something we are still designing. I hope that answers your question. :-) |
Sorting simply according to increasing unicode values would be very wrong in most countries. For example, there exists three symbols with unicode values Å = 197, Æ = 198, Ø = 216. However in the danish language you traditionally sort them Æ, Ø, Å. Realm will sort unicode symbols 0...591 (upto and including Latin Extended 2) in the english ("en") locale. This gives the sorting order that you quoted, which is the correct order for most countries that have the letters "é" and "h" in their alphabet. This method is not perfect, though. There are minor flaws for some letters in some countries. Unicode symbols beyond Latin Extended 2 will be sorted simply according to their unicode value. |
Wow, I am just switching to Realm today and this is kind of a big deal. Seems like I will have to store two of almost every property in my database. Has this changed at all since January of 2016? |
any progress on the topic since the question was raised in 2015? |
@Heki2017 Unfortunately not. We are not prioritizing features by the date they were created. Although this is something we surely would like to support there are (still) other bugs or features that are more requested for the time being. |
No case insensitive sorting, no custom sorting. These things should be pointed in your documents when someone is thinking of using it in a project. Its a flaw, own it and make sure people that wanna use it know it from day 1. You only find out when its too late already. Gotta hack some stuff now, great! |
Any movement on this? It's been just over 5 years since this was opened. Not having a basic feature like this is pretty surprising. Foundation has |
I was using LexoRank to sort my documents in FireStore, this is quite important for my project, any updates? |
uh, still no realm-native lowercase sorting in 2024? |
Good lord, this has been open for a decade.
If I may be so bold: a query engine that can't do case-insensitive sorting is a broken query engine. This is what Realm produces:
The only suggested workarounds are:
Great. |
This is what developing with Realm often feels like. Imagine Realm is a car. It has:
And:
You: "How do I get it out of my garage?" |
Another option is to generate the index field in memory Personally I added a grdb SQLite for full text search. But now I have two redundant storages. |
Is it possible to get query results sorted in a case insensitive way so that:
Cat (capital C)
comes before cow (lower case c)?
Thanks
The text was updated successfully, but these errors were encountered: