---
title: "sortedArray(comparator:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsorderedset/sortedarray(comparator:)"
---

# sortedArray(comparator:)

Returns an array that lists the receiving ordered set’s elements in ascending order, as determined by the comparison method specified by a given NSComparator block

## Declaration

```swift
func sortedArray(comparator cmptr: (Any, Any) -> ComparisonResult) -> [Any]
```

## Parameters

- `cmptr`: A comparator block.

## Return Value

Return Value An array that lists the receiving ordered set’s elements in ascending order, as determined by the comparison method specified cmptr.

## See Also

### Creating a Sorted Array

- [sortedArray(using:)](foundation/nsorderedset/sortedarray(using:).md)
- [sortedArray(options:usingComparator:)](foundation/nsorderedset/sortedarray(options:usingcomparator:).md)
