<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSMutableArray/sort(using:)-537vs",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSMutableArray(im)sortUsingSelector:"
  },
  "title" : "sort(using:)"
}
-->

# sort(using:)

Sorts the receiver in ascending order, as determined by the comparison method specified by a given selector.

```
func sort(using comparator: Selector)
```

## Parameters

`comparator`

A selector that specifies the comparison method to use to compare elements in the array.

    The     `comparator`     message is sent to each object in the array and has as its single argument another object in the array. The     `comparator`     method should return     `NSOrderedAscending`     if the array is smaller than the argument,     `NSOrderedDescending`     if the array is larger than the argument, and     `NSOrderedSame`     if they are equal.

## See Also

[`-  sortedArrayUsingSelector:`](/documentation/Foundation/NSArray/sortedArray(using:)-9nhh9)

Returns an array that lists the receiving array’s elements in ascending order, as determined by the comparison method specified by a given selector.



---

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)