struct ComparableComparator<Compared> : SortComparator, Sendable where Compared : Comparable
<aside>
π‘ Comparable
νλ‘ν μ½μ μ€μνλ νμ
μ λν λΉκ΅ μκ³ λ¦¬μ¦. Comparable
νλ‘ν μ½μ ꡬν체, μ¦ λΉκ΅ μ°μ°μλ₯Ό ν΅ν΄ μΈμ€ν΄μ€λ₯Ό λΉκ΅νλ€.
</aside>
iOS 16 μ΄μ κΉμ§λ ComparableComparator
μ μ§μ μ κ·Όν μΌμ΄ μμλ€. μ ν λ¬Έμμ μνλ©΄ ComparableComparator
λ₯Ό μ¬μ©νλ λ°©λ²μ KeypathComparator
λ₯Ό μμ±νλ©΄μ comparator
μΈμλ₯Ό μ λ¬νμ§ μλ κ²λΏμ΄μλλ°, KeypathComparator
μμ comparator
μ 보λ₯Ό μ‘°νν μ μλ λ°©λ²μ μ 곡νμ§ μμκΈ° λλ¬Έμ΄λ€.
2023λ
(iOS 17+, β¦)μ μμ±μκ° μΆκ°λλ©΄μ κ°λ°μλ€μ΄ ν΄λΉ ꡬ쑰체μ μ κ·Όν μ μκ² λμλ€. SortComparator
μ μ¬μ©μ²μμ μ¬μ©λλ€.
init(order: SortOrder = .forward)
// conforming SortComparator
func compare(_ lhs: Compared, _ rhs; Compared) -> ComparisonResult
var order: SortOrder
// SortComparator inherits Hashable
func hash(into hasher: inout Hasher)
var hashValue: Int { get }
// Hashable inherits Equatable
static func == (a: ComparableComparator<Compared>, b: ComparableComparator<Compared>) -> Bool
static func != (lhs: ComparableComparator<Compared>, rhs: ComparableComparator<Compared>) -> Bool