Structure
ComparableComparator
iOS 15.0+
iPadOS 15.0+
Mac Catalyst 15.0+
macOS 12.0+
tvOS 15.0+
watchOS 8.0+
A comparator that compares types according to their conformance to the comparable protocol.
struct ComparableComparator<Compared> where Compared : Comparable
Overview
The comparator uses the relevant type’s doc://com.apple.documentation/documentation/swift/comparable implementation to compare instances.
Topics
Initializers
Instance Properties
var order: SortOrderThe sort order that the comparator uses to compare.
Instance Methods
func compare(Compared, Compared) -> ComparisonResultProvides the relative ordering of two elements.
Relationships
Conforms To
SortComparatorSwift.EquatableSwift.HashableSwift.SendableSwift.SendableMetatype