protocol SortComparator<Compared> : Hashable

<aside> πŸ’‘ νŠΉμ • νƒ€μž…μ— λŒ€ν•œ 비ꡐ μ•Œκ³ λ¦¬μ¦˜. 두 ν•­λͺ©μ„ λΉ„κ΅ν•˜κ±°λ‚˜ μ—¬λŸ¬ ν•­λͺ©μ„ μ •λ ¬ν•  λ•Œ μ‚¬μš©λœλ‹€.

</aside>

iOS 15+ μ΄ν›„λ‘œ μΆ”κ°€λ˜μ–΄ 기쑴의 Comparator 별칭을 λŒ€μ²΄ν•œλ‹€. compare λ©”μ†Œλ“œλŠ” Comparator 별칭 νƒ€μž…κ³Ό λ™μΌν•œ νƒ€μž…μ΄λ‹€.

SortDescriptorλŠ” Obj-C κ΅¬ν˜„μ²΄ NSSortDesciptor의 ν˜Έν™˜μ„±μ„ μœ„ν•΄ λΈŒλ¦Ώμ§€λœ Swift κ°μ²΄λΌλŠ” μΈ‘λ©΄μ—μ„œ μ‚¬μš©μ„±μ— μ œμ•½μ΄ μžˆλŠ” 반면, SortComparator ν”„λ‘œν† μ½œμ€ Obj-C λŸ°νƒ€μž„μ— μ˜μ‘΄ν•˜μ§€ μ•ŠμŒμœΌλ‘œμ„œ λ‹€μ–‘ν•œ μ˜μ—­μ—μ„œ 쒀더 보편적으둜 μ‚¬μš©λ  수 μžˆλ„λ‘ ν•œλ‹€.

λ‹€μŒ νƒ€μž…λ“€(+ν”„λ‘œν† μ½œ)μ—μ„œλŠ” SortComparatorλ₯Ό ν™œμš©ν•˜μ—¬ 비ꡐ 및 μ •λ ¬ κΈ°λŠ₯을 μ œκ³΅ν•œλ‹€:

μš”κ΅¬μ‚¬ν•­

associatedtype Compared
var order: SortOrder
func compare(_ lhs: Self.Compared, _ rhs: Self.Compared) -> ComparisonResult

Self == String.Comparator인 경우 λ‹€μŒ νƒ€μž… ν”„λ‘œνΌν‹°κ°€ κΈ°λ³Έ μ œκ³΅λœλ‹€.

static var localized: String.Comparator { get }
static var localizedStandard: String.Comparator { get }

μ€€μˆ˜ 타μž