-
Notifications
You must be signed in to change notification settings - Fork 586
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 for compareFunction for sorted method #3770
Comments
@andrei-tofan The short answer is no. The reason why we haven't added the functionality so far is that we fear that the many callbacks to JavaScript will degenerate the performance to an unacceptable level. |
Hi @kneth. Your point about performance concerns is understandable. Is there another way this could be solved? For example by passing a sort priority string into realm when opening the DB (or at any point that is more suitable), so you could do the sorting natively for performance reasons? This would make it super flexible for us as developers to control the sorting and be sure it behaves the same as in JS. For example, a sort string could look like this for swedish: '� _-,;:!¡?¿.·'"«»()[]{}§¶@*/&#%`´^¯¨¸°©®+±÷×<=>¬|¦~¤¢$£¥01¹½¼2²3³¾456789aAbBcCçÇdDðÐeEéÉèÈêÊëËfFgGhHiIíÍìÌîÎïÏjJkKlLmMnNñÑoOºóÓòÒôÔöÖõÕøØpPqQrRsSßtTuUúÚùÙûÛüÜvVwWxXyYýÝÿzZþÞµªáÁàÀâÂåÅäÄãÃæÆ', and like this for english '� _-,;:!?.'"()[]{}@*/&#%`^+<=>|~$0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ', |
Hi again @kneth. What do you think about my suggestion from 7 days ago? Thx! |
A generic solution for sorting isn't trivial to implement as outlined in realm/realm-core#2573. In particular, Android doesn't have support for ICU. Realm Core doesn't provide a callback mechanism, but it might be worth considering instead of keep waiting for Android NDK to provide the optimal solution. |
Hi @kneth, Pinging this issue to see if you have the possibility to look into this further? Thx! |
@jaltin We haven't priorities it before but I will bring it up after the holidays. |
In the latest version of RealmSwift is possible to provide a compare function to the
sorted
method, this is very useful for more complex sorting and locale-aware sorting (sorting edge case - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare#using_options).Is there a way to supply a compare function to the sorted method? Didn't find an option in the documentation.
The text was updated successfully, but these errors were encountered: