mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-24 18:31:41 +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
|
Indicates that the `RawKeyPath` should be sorted in descending order
|
||||||
*/
|
*/
|
||||||
case descending(RawKeyPath)
|
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):
|
case .descending(let keyPath):
|
||||||
return NSSortDescriptor(key: keyPath, ascending: false)
|
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