<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/String/Comparator/init(options:locale:order:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:SS10FoundationE10ComparatorV7options6locale5orderACSo22NSStringCompareOptionsV_AA6LocaleVSgAA9SortOrderOtcfc"
  },
  "title" : "init(options:locale:order:)"
}
-->

# init(options:locale:order:)

Creates a `String.Comparator` with the given `CompareOptions` and
`Locale`.

```
init(options: String.CompareOptions, locale: Locale? = Locale.current, order: SortOrder = .forward)
```

## Parameters

`options`

The options to use for comparison.

`locale`

The locale to use for comparison. If `nil`, the
comparison is unlocalized.

`order`

The initial order to use for ordered comparison.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)