-
Notifications
You must be signed in to change notification settings - Fork 25
Support for descending sort when use grouping #60
Support for descending sort when use grouping #60
Conversation
I understand the issue, but i don't think you need to change all that stuff. The information you need is already passed in the methods, no need to change everything, just the sortSections method: private func sortSections() {
guard let sortd = request.sortDescriptors.first else { return }
let comparator: NSComparisonResult = sortd.ascending ? .OrderedAscending : .OrderedDescending
sections.sortInPlace { $0.keyPath.localizedCaseInsensitiveCompare($1.keyPath) == comparator }
} If you don't want to group, don't pass a EDIT: If travis fails, review the tests :) |
Well, I see, I lost the local But, by the way, what for do you need to store |
As it is a NSFetchedResultsController-like Library, we want our API to be as similar as possible to it. |
Good point. Okay, I got it. |
Feel free to do it :) |
👍 |
sections.sortInPlace { $0.keyPath.localizedCaseInsensitiveCompare($1.keyPath) == NSComparisonResult.OrderedAscending } | ||
guard let sortd = request.sortDescriptors.first else { return } | ||
let comparator: NSComparisonResult = sortd.ascending ? .OrderedAscending : .OrderedDescending | ||
sections.sortInPlace { $0.keyPath.localizedCaseInsensitiveCompare($1.keyPath) == comparator } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sections.sortInPlace { $0.keyPath.localizedCaseInsensitiveCompare($1.keyPath) == sortd.ascending }
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comparator
is NSComparisonResult
but sortd.ascending
is Bool
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My fault
👍 |
…ting Support for descending sort when use grouping
Thanks @bronenos |
👏 |
Made public just a boolean, whether or not use the grouping.
If true, then use the first sorter as grouping path, automatically.