Instance Method


Sorts the objects within a section by their localized titles.


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



An array containing the model objects for a section.


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 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.


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

func section(for: Any, collationStringSelector: Selector) -> Int

Returns an integer identifying the section in which a model object belongs.