Initializes a sort descriptor with a given key path, ordering, and comparison selector.


init(key: String?, ascending: Bool, selector: Selector?)



The key path to use when performing a comparison.

For information about key paths, see Key-Value Coding Programming Guide.


true if the receiver specifies sorting in ascending order, otherwise false.


The method to use when comparing the properties of objects, for example localizedStandardCompare(_:). The selector must specify a method implemented by the value of the property identified by the key path. The selector used for the comparison is passed a single parameter, the object to compare against, and must return the appropriate ComparisonResult constant.

Return Value

A sort descriptor initialized with the specified key path, sort order, and comparison selector.

See Also

Initializing a Sort Descriptor

init(key: String?, ascending: Bool)

Initializes a sort descriptor a given key path and sort order.

init(key: String?, ascending: Bool, comparator: Comparator)

Initializes a sort descriptor with a given key path and ordering, and a comparator block.