---
title: "sorted(using:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/sequence/sorted(using:)-95lls"
---

# sorted(using:)

Returns the elements of the sequence, sorted using the given comparator to compare elements.

## Declaration

```swift
func sorted<Comparator>(using comparator: Comparator) -> [Self.Element] where Comparator : SortComparator, Self.Element == Comparator.Compared
```

## Parameters

- `comparator`: The comparator to use in ordering elements

## Return Value

Return Value An array of the elements sorted using comparator.
