---
title: "sort(using:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/mutablecollection/sort(using:)-9a05g"
---

# sort(using:)

Sorts the collection using the given array of SortComparators to compare elements.

## Declaration

```swift
mutating func sort<S, Comparator>(using comparators: S) where S : Sequence, Comparator : SortComparator, Comparator == S.Element, Self.Element == Comparator.Compared
```

## Parameters

- `comparators`: An array of comparators used to compare elements. The first comparator specifies the primary comparator to be used in sorting the sequence’s elements. Any subsequent comparators are used to further refine the order of elements with equal values.
