How to display values of attributes (facets) in alphabetical order

In the search result page, the values of the attribute not rendered alphabetically

Is there any way to reorder it?

For Example, My attribute name is color and its values are Yellow,Red, Black, Green.

It was Reordered it in the left side of the search result page.

But I want to reorder it alphabetically like below

Black, Green, Red, Yellow.

How can I do this ??

Hi @jayashreen,

Thanks for asking. This is a good use case for sortBy in the refinementListwidget. By setting your array list of colors, you can sort by their names as you wish. For example:

const colors = ['Black', 'Green', 'Red', 'Yellow'];

search.addWidget(
  instantsearch.widgets.refinementList({
    container: '#color',
    attribute: 'color',
    sortBy(a, b) {
      return colors.indexOf(a.label) - sizes.indexOf(b.label);
    },
  })
);

Hi @ajay,

Can I do this in algolia dashboard ??

Hi @jayashreen,

This cannot be done in Algolia Dashboard, apologies for the inconvenience.