---
title: "Walkthrough: Adding an attribute as a sorting option"
slug: "walkthrough--adding-an-attribute-as-a-sorting-option"
abstract: "How to add a sorting option in Sitecore Discover with an attribute not included during setup."
---
# Walkthrough: Adding an attribute as a sorting option

By default, search results are displayed in descending order by relevancy score, but you can create other sorting options using the Customer Engagement Console (CEC). For example, you might create options for users to sort results by product name, price, or total sales.

This walkthrough describes how to:

- Enable the sorting option feature for an attribute.
- Add that attribute as a sorting option for your domain.
- Turn on the sorting option in global widget settings.

## Enable the sorting option feature for an attribute

In order for an attribute to be accessible for use in sorting, you must enable the sorting option feature.

> [!note]
> Only attributes with the following data types can be added as sorting options: *string*, *integer*, *float*, and *timestamp*.

To enable sorting by an attribute:

1. In the CEC, on the menu bar, go to **Administration** > **Domain Settings** > **Attributes**.
2. To filter the list of attributes by entity, in the **Entity** drop-down, select the checkbox for the type of entity you want to show and click **Apply**.
3. To search for an attribute, in the search bar, enter the attribute name. Then, click on the attribute in the tabular list. This opens the attribute configuration page.
4. On the left vertical menu bar, on the **Use for Features** tab, select the **Sorting Options** check box.
5. Click **Save**.

## Add an attribute as a sorting option

After making an attribute available as a sorting option, you must add it to the sorting options list in order for it to be used on your domain.

To add an attribute to the sorting options list:

1. On the menu bar, click **Administration** > **Domain Setting** > **Feature Configuration**.
2. Click **Sorting Options** and then click **Add Sorting Option**![Plus_add__grey.png](https://doc.sitecore.com/api/markdown-image/discover/en/users/discover-user-guide/images/Plus_add__grey.png).
3. Click **edit** ![pencil_grey.png](https://doc.sitecore.com/api/markdown-image/discover/en/users/discover-user-guide/images/pencil_grey.png) at the top of the new sorting option.
4. In the **DISPLAY NAME** field, enter a short but descriptive name.
5. In the **API NAME** field, enter a name for the sorting option without escape characters and then click **Save**.
6. In the sorting type drop-down menu, click *Attribute Sorting*.
7. In the **Select Attribute** drop-down menu, click the attribute you want to sort by.
8. In the sorting direction drop-down menu, click *Ascending* or *Descending*.
9. Optionally, you can add additional tie-breakers by clicking Add Sorting Criteria on the sorting option card and following steps 6 through 8.
10. Click **Save**, then click **Publish**. This opens a dialog box. Confirm your changes by clicking **Publish** again in the dialog box.

## Turn on the sorting option in global widget settings

Finally, we recommend that you turn on your new sorting option in the global widget settings. If you do not turn on *any* sorting options in global widget settings, *all* sorting options created in feature configuration are returned by the API. However, if any sorting options are turned on in the global widget settings, only the ones that are turned on are returned by the API.

Turning on sorting options in global widget settings allows you to have more control over which sorting options are returned by creating a default configuration that can be overridden at the individual widget level with rules. It also makes it possible to create many potential sorting options in feature configuration and then only turn on the ones you need.

> [!important]
> Although we recommend you turn on sorting options in the global widget, if no existing sorting options are turned on, do not complete this step or all other sorting options will be disabled.

To configure a sorting option in the global widget:

1. In the CEC, on the menu bar, click **Global Resources**, then click **Global Widget**.
2. On the **Global Widget Settings** tab, click the **Sorting** card.
3. On the card for the new sorting option, turn on the switch.
4. Optionally, if you want this sorting option to be the default, click **Make Default**.
5. Click **Save**, then click **Publish**. This opens a dialog box. Confirm your changes by clicking **Publish** again in the dialog box.