<!--
{
  "availability" : [
    "iOS: 3.0.0 -",
    "iPadOS: 3.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UILocalizedIndexedCollation/sortedArray(from:collationStringSelector:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UILocalizedIndexedCollation(im)sortedArrayFromArray:collationStringSelector:"
  },
  "title" : "sortedArray(from:collationStringSelector:)"
}
-->

# sortedArray(from:collationStringSelector:)

Sorts the objects within a section by their localized titles.

```
func sortedArray(from array: [Any], collationStringSelector selector: Selector) -> [Any]
```

## Parameters

`array`

An array containing the model objects for a section.

`selector`

The selector of a method implemented by the objects in `array` that returns the string to use for sorting the objects. The method represented by the selector must take no arguments and return an <doc://com.apple.documentation/documentation/Foundation/NSString> object. For example, you might specify the selector for a name property of the object.

## Return Value

A new array containing the sorted items from the original `array` parameter.

## Discussion

The table-view controller creates the array of objects for a section (`array`) as part of iterating through its model objects with calls to the [`section(for:collationStringSelector:)`](/documentation/UIKit/UILocalizedIndexedCollation/section(for:collationStringSelector:)) method. This method should be called on each local section array.

---

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)