Instance Method

compare(_:to:)

Returns a comparison result value that indicates the sort order of two objects.

Declaration

func compare(_ object1: Any, to object2: Any) -> ComparisonResult

Parameters

object1

The object to compare with object2. This object must have a property accessible using the key-path specified by key.

object2

The object to compare with object1. This object must have a property accessible using the key-path specified by key.

Return Value

ComparisonResult.orderedAscending if object1 is less than object2, ComparisonResult.orderedDescending if object1 is greater than object2, or ComparisonResult.orderedSame if object1 is equal to object2.

Discussion

The ordering is determined by comparing the values specified by key of object1 and object2 using the selector specified by selector.

See Also

Using Sort Descriptors

var reversedSortDescriptor: Any

Returns a sort descriptor with the sort order reversed.

func allowEvaluation()

Forces a sort descriptor that was securely decoded to allow evaluation.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software