Comparator
A String
comparison performed using the given comparison options and locale.
- iOS
- 15.0+
- macOS
- 12.0+
- tvOS
- 15.0+
- watchOS
- 8.0+
struct Comparator
A String
comparison performed using the given comparison options and locale.
struct Comparator
import FoundationInternationalization
import Swift
@frozen struct String
A Unicode string value that is a collection of characters.
struct StandardComparator
Compares String
s using one of a fixed set of standard comparison algorithms.
protocol Decodable
A type that can decode itself from an external representation.
protocol Encodable
A type that can encode itself to an external representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable : Equatable
A type that can be hashed into a Hasher
to produce an integer hash value.
protocol Sendable
@preconcurrency protocol SortComparator<Compared> : Hashable, Sendable
A comparison algorithm for a given type.
init(_ standardComparison: String.StandardComparator)
Creates a String.Comparator
that represents the same comparison as the given String.StandardComparator
.
init(from decoder: any Decoder) throws
init(options: String.CompareOptions, order: SortOrder = .forward)
let locale: Locale?
The locale to use for comparison if the comparator is localized, otherwise nil.
let options: String.CompareOptions
The options to use for comparison.
var order: SortOrder
func compare(_ lhs: String, _ rhs: String) -> ComparisonResult
func encode(to encoder: any Encoder) throws
func hash(into hasher: inout Hasher)
static func != (lhs: Self, rhs: Self) -> Bool
Returns a Boolean value indicating whether two values are not equal.