# Sorting

To request sorted data on initial load, configure the sort options in the `DataSourceSortDescriptorFactory`. The `ToDataSourceResult()` extension method will return only the sorted data in the response object.

* The `Sort` method sets the initial sorts.

```Razor HtmlHelper
    @(Html.Kendo().DataSource<ProductViewModel>()
        .Name("myDataSource")
        .Ajax(datasource => datasource
            .Read(read => read.Action("Products_Read", "Home"))
            .Sort(sort =>
            {
                //Sort by the UnitsInStock in descending order.
                sort.Add(product => product.UnitsInStock).Descending();
                // Then sort by the ProductName in ascending order.
                sort.Add(product => product.ProductName);
            })
        )
    )
```

```Razor TagHelper
    <kendo-datasource name="myDataSource" type="DataSourceTagHelperType.Ajax">
        <transport>
            <read url="@Url.Action("Products_Read", "Home")"/>
        </transport>
        <sorts>
            <sort field="UnitsInStock" direction="desc" />
            <sort field="ProductName" />
        </sorts>
    </kendo-datasource>
```

## See Also

* [Server-Side API](https://www.telerik.com/aspnet-core-ui/documentation/api/datasource)
