---
title: "sort(options:usingComparator:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsmutablearray/sort(options:usingcomparator:)"
---

# sort(options:usingComparator:)

Sorts the receiver in ascending order using the specified options and the comparison method specified by a given Comparator block.

## Declaration

```swift
func sort(options opts: NSSortOptions = [], usingComparator cmptr: (Any, Any) -> ComparisonResult)
```

## Parameters

- `opts`: A bitmask that specifies the options for the sort (whether it should be performed concurrently and whether it should be performed stably).
- `cmptr`: A comparator block.

## See Also

### Related Documentation

- [sortedArray(using:)](foundation/nsarray/sortedarray(using:)-82wi1.md)

### Rearranging Content

- [exchangeObject(at:withObjectAt:)](foundation/nsmutablearray/exchangeobject(at:withobjectat:).md)
- [sort(using:)](foundation/nsmutablearray/sort(using:)-4eh07.md)
- [sort(comparator:)](foundation/nsmutablearray/sort(comparator:).md)
- [sort(_:context:)](foundation/nsmutablearray/sort(_:context:).md)
- [sort(using:)](foundation/nsmutablearray/sort(using:)-537vs.md)
