Realm search results are sorted by several ios properties

I am trying to sort RLMResults by 2 properties, 1st sort value, and 2nd name, but no luck. I get the wrong results when I try to sort by 2 properties.

I want me to sort the results using the sort value, and then in alphabetical order.

self.allTasks = [[[Task allObjects]
                 sortedResultsUsingProperty:@"priorityLevelSortValue" ascending:YES]
                 sortedResultsUsingProperty:@"taskName" ascending:YES];

Any help would be very noticeable.

Thank.

+4
source share
1 answer

Use -[RLMResults sortedResultsUsingDescriptors:]to sort by several properties:

[[Task allObjects] sortedResultsUsingDescriptors:@[
    [RLMSortDescriptor sortDescriptorWithProperty:@"priorityLevelSortValue" ascending:YES],
    [RLMSortDescriptor sortDescriptorWithProperty:@"taskName" ascending:YES]
]];
+8
source

All Articles