Support sorting by property in child object
Example:
Using the classes below:
public class TypeA extends RealmObject {
private String name;
}
public class TypeB extends RealmObject {
private int number;
private TypeA someType;
}
I can't perform:
Realm realm = Realm.getInstance(this);
RealmQuery<TypeB> query = realm.where(TypeB.class);
query.findAll().sort("someType.name"); // Throws java.lang.IllegalArgumentException: Field 'someType.name' does not exist.
Hi @snotyak Thank you for a detailed bug report. That feature is currently not supported, but the error message isn't very precise. I have updated the error message to be more clear until we can add support for this.
+1
:+1:
+1
@cmelchior I see that the exception you threw in the merge above is no longer a part of master. Has this been fixed?
:+1:
Hello, do you have any ETA on this feature. it will be life saving ! Thanks a lot.
+1
+1 Query filtering works well with subproperties, so it would make sense that sorting can be used in conjuction.
hey guys, this is solved?
+1 I'm trying to implement a RecyclerView backed by a realmResults that is capable to group and sort by any of the properties of the base class, creating a "sectionedAdapter" on the fly. If I want to group by any of the related RealmObject of the base RealmObject, I also need to order the list by the same property hence the need of sort by child. Also I'm using retrolambda and Java 8 streams that make the code very clean and straightforward, however, as I can't make RealmObject implement "IComparable" I'm also stuck there: If I transform the RealmResults into a list to overcome the sorted by child, I need to make the child Icomparable, but I can't...
:+1:
+1
any updates here? :+1:
+1
It has been more than a year and 4 months and still no update on the feature.
+1
This is a duplicate of #672, so moving all the +1's from here to there and closing this as an duplicate.