Skip to main content
Signature

Explore example code

Browse the SortBy example code on GitHub.

About this widget

This widget displays a list of indices, allowing a user to change the way hits are sorting (with replica indices). Another common use case for this widget is to let users switch between different indices. For this widget to work, you must define all indices that you pass down as options as replicas of the main .

Examples

Kotlin

Low-level API

To add SortBy to your search experience, use these components:
  • Searcher. The Searcher that handles your searches.
  • SortByViewModel. The logic applied to the index sorting/switching.
  • SortByViewAutocomplete. The concrete view implementing SortByView.
  • IndexPresenter. Optional. The presenter that converts an Index to a String output.
Kotlin

Compose UI

Kotlin

Parameters

indexes
Map<Int, String>
required
The list of indices to search in.
searcher
HitsSearcher
required
The Searcher that handles your searches.
selected
Int?
default: null
The index to select. By default, none is selected.

View

view
SortByView
required
The view that renders the list of indices.InstantSearch includes the SortByViewSpinner and SortByViewAutocomplete implementations.
presenter
IndexPresenter
default:"IndexPresenterImpl"
The presenter that defines the way we want to display an index, taking as input an Index and returning a String.
Kotlin
Last modified on July 10, 2026