> ## Documentation Index
> Fetch the complete documentation index at: https://algolia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Sorting refinements

> Learn how to sort your refinement lists with InstantSearch iOS.

<div className="not-prose algolia-flavor-switcher">
  <div className="afs-dropdown">
    <div className="afs-trigger" role="button" tabIndex="0" aria-haspopup="listbox">
      <span className="afs-current">iOS</span>

      <svg className="afs-chevron lucide lucide-chevron-down" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
        <path d="m6 9 6 6 6-6" />
      </svg>
    </div>

    <ul className="afs-menu" role="listbox">
      <li role="option" aria-selected="true"><a className="afs-option is-current" href="/doc/guides/building-search-ui/ui-and-ux-patterns/sorting-refinements/ios"><span className="afs-option-name">iOS</span><span className="afs-option-lib">InstantSearch iOS</span></a></li>
      <li role="option" aria-selected="false"><a className="afs-option" href="/doc/guides/building-search-ui/ui-and-ux-patterns/sorting-refinements/android"><span className="afs-option-name">Android</span><span className="afs-option-lib">InstantSearch Android</span></a></li>
    </ul>
  </div>
</div>

<Info>
  Starting May 1, 2024,
  Apple requires all iOS apps to include a privacy manifest.
  For more information, see [Privacy manifest](/doc/guides/building-search-ui/resources/privacy-manifest/ios/).
</Info>

## Sort refinements

You can sort refinement lists alphabetically or by count. For each option, you can choose ascending or descending order.

## Example

You can specify the sort order of the `RefinementTableWidget` or `RefinementCollectionWidget` by using the `sortBy` property:

```swift Swift icon=code theme={"system"}
refinementTableWidget.sortBy = "count:asc"
refinementTableWidget.sortBy = "count:desc"
refinementTableWidget.sortBy = "name:asc"
refinementTableWidget.sortBy = "name:desc"

refinementCollectionWidget.sortBy = "count:asc"
refinementCollectionWidget.sortBy = "count:desc"
refinementCollectionWidget.sortBy = "name:asc"
refinementCollectionWidget.sortBy = "name:desc"
```
