SortDescriptor
public struct SortDescriptor<T>
a comparator used to compare two objects
-
Initialize a sort descriptor with a custom comparator
Declaration
Swift
public init<V: Comparable>(_ keyPath: KeyPath<T, V>, ascending: Bool = true)Parameters
keyPathA keypath for the type being sorted
ascendingIf the comparison should order ascending
-
Initialize a sort descriptor with a custom comparator
Declaration
Swift
public init(_ comparator: @escaping ((T, T) -> SortDescriptorResult))Parameters
comparatorA comparator returning a comparison result
-
Compare two objects
Declaration
Swift
public func compare(_ a: T, to b: T) -> SortDescriptorResultParameters
aThe first object
bThe second object
Return Value
A SortDescriptorResult for the two objects.