---
title: "Sorting content"
slug: "sorting-content"
abstract: "Learn how to use the Search and Recommendation API for Sitecore Search to sort content."
---
# Sorting content

You can add a `widget.items.search.sort` object to your request to sort content, that is, determine the order in which they appear in the search results.

> [!note]
> Before you can sort content, make sure that an administrator configures [sorting options](https://doc.sitecore.com/search/en/users/search-user-guide/en/sorting-options.html) in Search.

When you use the `widget.items.search.sort` object, pass the name of the sorting option as the `sort.value.name`.

For the data model of this object, see the [Search and Recommendation API reference](https://doc.sitecore.com/search/en/developers/search-and-recommentation-api/index.html) .

In this example, you want to:

- Sort all results in ascending alphabetical order. You have a previously created sorting option called `title`. In the request, pass `title` as the `name` and `asc` as the `order`.
- Get only the title. For this use the `widget.items.search.content` object and pass `title` in the fields array.

The following code sample shows how to create a request:

```JSON
{
    "widget": {
        "items": [
            {
                "rfk_id": "rfkid_7",
                "entity": "content",
                "search": {
                    "content": {
                        "fields": [
                            "title"
                        ]
                    },
                    "sort": {
                        "value": [
                            {
                                "name": "title",
                                "order": "asc"
                            }
                        ]
                    },
                    "limit": 3,
                    "offset": 0
                }
            }
        ]
    },
    "context": {
        "locale": {
            "country": "us",
            "language": "en"
        },
        "user": {
            "uuid": "159871551-1g-i4-4x-1p-f5tdhddqwvywv7b9g2vy-1664852644904"
        }
    }
```

The following is the response to the request:

```JSON
{
    "widgets": [
        {
            "rfk_id": "rfkid_7",
            "entity": "content",
            "content": [
                {
                    "id": "https___www_sitecore_com_knowledge-center_blog_2019_10_commerce-twitter-chat",
                    "source_id": "388218",
                    "title": "#ReinventingCommerce"
                },
                {
                    "id": "https___www_sitecore_com_knowledge-center_blog_2019_10_commerce-twitter-chat",
                    "source_id": "407033",
                    "title": "#ReinventingCommerce"
                },
                {
                    "id": "https___www_sitecore_com_webinars_2019_modular-content-creation-for-better-omni-channel",
                    "source_id": "388218",
                    "title": "**You need modular content creation for better omnichannel**"
                }
            ],
            "total_item": 5858,
            "limit": 3,
            "offset": 0
        }
    ],
    "dt": 66,
    "ts": 1669436439108
}
```

In the response `widgets.content` object, you can see that all content is sorted by descending alphabetical order of their *title*.