1e41f4b71Sopenharmony_ci# Sorting by Indexes
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci## When to Use
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ciWhen 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.
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ci## How to Develop
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ciFor details about how to use related APIs, see [IndexUtil](../reference/apis-localization-kit/js-apis-i18n.md#indexutil8).
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci1. Import the **i18n** module.
12e41f4b71Sopenharmony_ci   ```ts
13e41f4b71Sopenharmony_ci   import { i18n } from '@kit.LocalizationKit';
14e41f4b71Sopenharmony_ci   ```
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ci2. Create an **IndexUtil** object.
17e41f4b71Sopenharmony_ci   ```ts
18e41f4b71Sopenharmony_ci   let indexUtil = i18n.getInstance(locale?:string);  // The default value of locale is the current system locale.
19e41f4b71Sopenharmony_ci   ```
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci3. Obtain the index list.
22e41f4b71Sopenharmony_ci   ```ts
23e41f4b71Sopenharmony_ci   let indexList = indexUtil.getIndexList();
24e41f4b71Sopenharmony_ci   ```
25e41f4b71Sopenharmony_ci
26e41f4b71Sopenharmony_ci**Development Example**
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ci```ts
29e41f4b71Sopenharmony_ci// Import the i18n module.
30e41f4b71Sopenharmony_ciimport { i18n } from '@kit.LocalizationKit';
31e41f4b71Sopenharmony_ci// Create indexes in a single language.
32e41f4b71Sopenharmony_cilet indexUtil = i18n.getInstance("zh-CN");
33e41f4b71Sopenharmony_cilet indexList = indexUtil.getIndexList(); // ["...", "A", "B", "C", "D", "E" ... "X", "Y", "Z", "..."]
34e41f4b71Sopenharmony_ci// Create indexes in multiple languages.
35e41f4b71Sopenharmony_ciindexUtil.addLocale("ru-RU");
36e41f4b71Sopenharmony_ciindexList = 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,…,А,Б,В,Г,Д,Е,Ж,З,И,Й,К,Л,М,Н,О,П,Р,С,Т,У,Ф,Х,Ц,Ч,Ш,Щ,Ы,Э,Ю,Я,...
37e41f4b71Sopenharmony_ciindexUtil.getIndex ("Hello"); // Index H
38e41f4b71Sopenharmony_ci```
39