Skip to content
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 custom sorting in RealmResult and RealmList #3625

Closed
snowpong opened this issue Oct 12, 2016 · 3 comments
Closed

Support custom sorting in RealmResult and RealmList #3625

snowpong opened this issue Oct 12, 2016 · 3 comments

Comments

@snowpong
Copy link

Goal

I want to be able to sort RealmResult or RealmList in a custom way. For example it is impossible to sort in Realm for Android by Location. I know there is a specific issue tracking this, but thinking more generally - there will always be another type or way of sorting you haven't gotten around to implementing.

Expected Results

I can implement my own https://developer.android.com/reference/java/util/Comparator.html or similar, and use it directly in a Realm query.

Actual Results

I have to copy the result to a local list and run my custom sort there, loosing the benefits of change listeners etc.

@Zhuinden
Copy link
Contributor

#2313

#2744

@cmelchior
Copy link
Contributor

Hi @snowpong . Thanks for the suggestion. As @Zhuinden points out this is already being tracked by especially #2313. The biggest problem with a custom sorting Comparator is that the sorting is done in C++ while the Comparator is java code. Calling back into Java to do sorting would probably be extremely expensive. That said we haven't really measured it yet, so it might be acceptable for small results.

In any case, i'll close this as an duplicate and let the discussion continue in #2313

@snowpong
Copy link
Author

@cmelchior Fair enough. I should have searched better when posting the feature request. I see the issue with crossing the JNI barrier and speed.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants