mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-14 13:13:33 +01:00
Merge pull request #205 from jannon/case-insensitive-orderby
add case-insensitive sortkeys
This commit is contained in:
@@ -48,6 +48,16 @@ public enum SortKey {
|
||||
Indicates that the `RawKeyPath` should be sorted in descending order
|
||||
*/
|
||||
case descending(RawKeyPath)
|
||||
|
||||
/**
|
||||
Indicates that the `RawKeyPath` should be sorted in ascending order in a case-insenstive manner
|
||||
*/
|
||||
case ascendingInsensitive(RawKeyPath)
|
||||
|
||||
/**
|
||||
Indicates that the `RawKeyPath` should be sorted in descending order in a case-insenstive manner
|
||||
*/
|
||||
case descendingInsensitive(RawKeyPath)
|
||||
}
|
||||
|
||||
|
||||
@@ -124,6 +134,12 @@ public struct OrderBy: FetchClause, QueryClause, DeleteClause, Hashable {
|
||||
|
||||
case .descending(let keyPath):
|
||||
return NSSortDescriptor(key: keyPath, ascending: false)
|
||||
|
||||
case .ascendingInsensitive(let keyPath):
|
||||
return NSSortDescriptor(key: keyPath, ascending: true, selector: #selector(NSString.localizedCaseInsensitiveCompare(_:)))
|
||||
|
||||
case .descendingInsensitive(let keyPath):
|
||||
return NSSortDescriptor(key: keyPath, ascending: false, selector: #selector(NSString.localizedCaseInsensitiveCompare(_:)))
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user