---
schema_version: "1"
id: 77b51fc20e9f74a63ce8bcca32158bd613f078d06902ac4cce6a35df86c7205e
title: Add a Sort Rule
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/commerce/264-0-0/comm_search_sort_rule_add.md
canonical_url: https://help.salesforce.com/s/articleView?id=commerce.comm_search_sort_rule_add.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 93008a7e5618d08c02a4cc4ff824deb1303daa818c3b39075f7f8820b12efb3d
description: Create a sort rule based on available products and product attributes to let customers arrange results in search and category pages for B2B Commerce stores.
products:
  - Commerce
  - B2B Commerce
release: "264"
---
# Add a Sort Rule

Create a sort rule based on available products and product attributes to let customers arrange results in search and category pages for B2B Commerce stores.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;"><a href="https://help.salesforce.com/s/articleView?id=commerce.comm_editions.htm&amp;language=en_US" target="_blank">View supported editions</a>.</td></tr></tbody></table>

[Which Salesforce Commerce Product Do I Have?](https://help.salesforce.com/s/articleView?id=commerce.comm_what_product.htm&language=en_US)

When creating a sort rule, keep these considerations in mind.

- You can configure up to 15 sortable fields.
- The default Best Match rule sorts output based on its relevance to the search results. Commerce Search uses the frequency of the search terms in each product and how often each term appears in the catalog to determine the sort order for the search output.
- You can’t delete the default Best Match rule, but you change the order in which it appears in the sort menu.
- Sort rules apply to simple products and variation child products. When your store’s results display settings are set to show parent product only, product variation can appear out of order in sorted search results. Commerce Search applies sort rules to the most relevant child product within a variation group, and search results return the variation parent product.
- Search results are sorted numerically only if you create a custom field of the Number type on the Product page. Custom fields with the Currency type are mapped as strings rather than numbers, which can result in non-numeric sorting.
- Sort rule IDs change each time a new sort rule is added.

1. In the navigation sidebar, select a store from the **Store** dropdown.
2. Select **Settings** | **Search**.
3. Click **Sort Rules**.
4. Click **New**.
5. In the New sort option window, select the product field name to use as a sort option.
    
    Before sorting results by price, select a price book on the Search tile’s Additional Settings tab.
    
    ![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-commerce-comm-264-0-0-production-enus/d863e308-482a-4dfa-8d20-2a94737d394a/images/icon_note.png)
    
    Note You can’t delete custom fields that you use to create sorting rules. To delete a custom field, first delete the sorting rule that uses that field.
6. Select an ascending or descending sort order.
    
    Values in the Sort Order Label menu change to reflect your sort order selection.
7. (Optional) Select a sort order label to append to the sort option in the sorting menu.
    
    The sort order label appears in parentheses after the product field name. This label can help clarify how sorting occurs. For example, alphabetically, numerically, by cost, or by the size of a product.
8. (Optional) Specify where the new rule appears in the sort menu.
    
    By default, a new sort option is added to the end of the menu. You can override this placement by changing its numerical menu position. Until a shopper or buyer selects a different rule, the sort order follows the first sort rule in the sort menu.
9. Save your changes.
10. On the Search Index tab, update the search index.
    
    Changes appear in the store after the next search index rebuild. See [Update the Commerce Search Index](https://help.salesforce.com/s/articleView?id=commerce.comm_search_index_build.htm&release=264.0.0&type=5 "Update your search index so that changes to your products appear on your search and category pages. You can manually update the index or turn on automatic system updates.").

#### See Also

- [Enable or Disable Sort for Search Results](https://help.salesforce.com/s/articleView?id=commerce.comm_search_sort_options_enable.htm&release=264.0.0&type=5 "Sorting is enabled for search and category pages in B2B Commerce stores by default. However, you can control whether customers can see the sorting menu that appears on these pages with the Results Layout component. You can change the sorting properties on any page that uses the Results Layout component.")
- [Edit or Delete a Sort Rule](https://help.salesforce.com/s/articleView?id=commerce.comm_search_sort_rule_edit_delete.htm&release=264.0.0&type=5 "You can edit a sort rule and change where it appears in the sorting menu of your B2B Commerce store. To remove a sort rule from the sorting menu, delete the rule.")
- [Select a Price Book for Sorting](https://help.salesforce.com/s/articleView?id=commerce.comm_search_sort_by_price_book.htm&release=264.0.0&type=5 "To arrange search results in your B2B store by price, select a price book for sorting. The price book you select is always used for sorting, regardless of whether a customer is assigned to a different price book based on buyer group or entitlement policy. Deleted, archived, or inactive products are excluded from search results, which are sorted based on the store’s default currency. If the store's default currency is set to one type, such as EUR, and you sort the products by another currency, such as USD, products without prices in the sorting currency but with prices in the default currency are still considered to have prices and are displayed in the middle of the sorted list, while products without prices in the default ‌appear at the end of the sorted list‌.")