compare(_:to:)
Returns a comparison result value that indicates the sort order of two objects.
Declaration
func compare(_ object1: Any, to object2: Any) -> ComparisonResultParameters
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.