init(key:ascending:selector:)
Creates a sort descriptor with a specified string key path, ordering, and comparison selector.
Declaration
init(key: String?, ascending: Bool, selector: Selector?)Parameters
- key:
The key path for performing a comparison.
For information about key paths, see 10000107i.
- ascending:
True if the receiver specifies sorting in ascending order; otherwise, False.
- selector:
The method to use when comparing the properties of objects, such as Localizedstandardcompare(_:). The selector must specify a method that you implement according to the value of the property that the key path identifies. Pass the selector a single parameter, the object to compare against, and it returns the appropriate Comparisonresult constant.
Return Value
A sort descriptor that initializes with the specified key path, sort order, and comparison selector.