1# Sorting by Indexes
2
3## When to Use
4
5When there are many options in a list, users need to slide the window to search for the target option. Sorting by indexes is here to help them quickly find the target option by way of creating an index for each option. It is actually a kind of labeling. For example, labels ABCD on the right of the contact page correspond to the initial letters of contact names. If you want to find John, clicking J will direct you to a list of names starting with J. When there are many options in a list, users need to slide the window to search for the target option. Sorting by indexes is here to help them quickly find the target option by way of creating an index for each option.
6
7## How to Develop
8
9For details about how to use related APIs, see [IndexUtil](../reference/apis-localization-kit/js-apis-i18n.md#indexutil8).
10
111. Import the **i18n** module.
12   ```ts
13   import { i18n } from '@kit.LocalizationKit';
14   ```
15
162. Create an **IndexUtil** object.
17   ```ts
18   let indexUtil = i18n.getInstance(locale?:string);  // The default value of locale is the current system locale.
19   ```
20
213. Obtain the index list.
22   ```ts
23   let indexList = indexUtil.getIndexList();
24   ```
25
26**Development Example**
27
28```ts
29// Import the i18n module.
30import { i18n } from '@kit.LocalizationKit';
31// Create indexes in a single language.
32let indexUtil = i18n.getInstance("zh-CN");
33let indexList = indexUtil.getIndexList(); // ["...", "A", "B", "C", "D", "E" ... "X", "Y", "Z", "..."]
34// Create indexes in multiple languages.
35indexUtil.addLocale("ru-RU");
36indexList = indexUtil.getIndexList(); // …,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,…,А,Б,В,Г,Д,Е,Ж,З,И,Й,К,Л,М,Н,О,П,Р,С,Т,У,Ф,Х,Ц,Ч,Ш,Щ,Ы,Э,Ю,Я,...
37indexUtil.getIndex ("Hello"); // Index H
38```
39