---
title: "sortedArray(from:collationStringSelector:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uilocalizedindexedcollation/sortedarray(from:collationstringselector:)"
---

# sortedArray(from:collationStringSelector:)

Sorts the objects within a section by their localized titles.

## Declaration

```swift
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

Return Value A new array containing the sorted items from the original array parameter.

## Discussion

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:) method. This method should be called on each local section array.

## See Also

### Preparing the sections and section indexes

- [section(for:collationStringSelector:)](uikit/uilocalizedindexedcollation/section(for:collationstringselector:).md)
