Skip to content

Instance Method

compare(_:_:)

iOS 15.0+ iPadOS 15.0+ Mac Catalyst 15.0+ macOS 12.0+ tvOS 15.0+ watchOS 8.0+
Provides the relative ordering of two items according to the ordering of the properties that the comparator’s key path references.
func compare(_ lhs: Compared, _ rhs: Compared) -> ComparisonResult

Parameters

lhs

The first property to compare.

rhs

The second property to compare.

Return Value

The relative ordering for the compared properties.

Discussion

The method returns flipped comparisons if the sort order is SortOrder.reverse.