I've got a one to many property that returns a RLMResults
for an objectsWhere:
query. I need to sort this data by linking up uid's in a linked list fashion (each object has a previousId
property which points to the uid
property of the object before it).
I can do this with an NSArray
with sortedArrayUsingComparator
like this:
myArray = [myArray sortedArrayUsingComparator:^NSComparisonResult(MyRLMObject *obj1, MyRLMObject *obj2) {
if ([obj1.parentTileId isEmpty]) { // head of the list must be sorted first
return NSOrderedDescending;
} else if ([obj1.previousId isEqualToString:obj2.uid]) {
return NSOrderedDescending;
} else {
return NSOrderedAscending;
}
}];
However, RLMResults only has sorting based on 1 property. Is there a way to get the same logic with RLMResults? As a fallback solution how can I convert RLMResults into NSArray to perform this?