realm-kotlin icon indicating copy to clipboard operation
realm-kotlin copied to clipboard

Feature request: Sort by a given list

Open sirambd opened this issue 2 years ago • 2 comments

Description Sometimes we would like to be able to sort on objects but in relation to a given list. Except that currently, we can only sort on a property in ASC or DESC.

Example

sort("type", arrayOf("shared", "favorite", "offline")).find()

sirambd avatar Feb 17 '23 15:02 sirambd

Currently Core doesn't support this type of querying. You can add a feature request there.

If you need to write code that supports this functionality you could do it at a Kotlin level by combining 3 queries and reducing the result in Kotlin itself. You can also use copyFromRealm on the output and do the computation in memory instead.

edualonso avatar Feb 20 '23 10:02 edualonso

@edualonso Ok thanks for your answer, and so I created the ticket in Core. But if not, we currently sort ourselves in kotlin so it works but having this feature would simplify a lot.

sirambd avatar Feb 20 '23 13:02 sirambd