# Sorting

**RadGridView** provides you with a built-in sorting functionality, which allows the user to easily sort the data by one of the columns.

![Telerik UI for WPF RadGridView sorting interface showing sorted data in the grid](https://www.telerik.com/products/wpf/documentation/assets/35c5266d79b0390b34df49d461482d4d/radgridview_functionaloverview_sorting_1.png)

You can define sorting criteria either in the XAML or in the code-behind.

```XAML
<telerik:RadGridView x:Name="radGridView"
                 AutoGenerateColumns="False">
    <telerik:RadGridView.SortDescriptors>
        <telerik:SortDescriptor Member="EmployeeID"
                            SortDirection="Ascending" />
    </telerik:RadGridView.SortDescriptors>
    
</telerik:RadGridView>
```

You can achieve the same result if you define your sorting criteria in the code-behind like this:

```C#
SortDescriptor descriptor = new SortDescriptor();
descriptor.Member = "EmployeeID";
descriptor.SortDirection = ListSortDirection.Ascending;
this.radGridView.SortDescriptors.Add(descriptor);
```

```VB.NET
Dim descriptor As New SortDescriptor()
descriptor.Member = "EmployeeID"
descriptor.SortDirection = ListSortDirection.Ascending
Me.radGridView.SortDescriptors.Add(descriptor)
```

> Note that since **SortDescriptors** property is a **collection**, you can add more than one **SortDescriptor** to a **RadGridView**.

> tip Consider using the code-behind approach only when changing the sorting criteria **run-time**.

> important If the RadGridView is bound to a collection that inherits **ICollectionView** that has a **CanSort** property set to **true**, the RadGridView\`s sorting is disabled and the sorting mechanism of the collection is used instead.

Check out the chapters entirely dedicated to the sorting functionality of **RadGridView** and find the answers to the following questions:

* What are the available [types of sorting](https://www.telerik.com/products/wpf/documentation/controls/radgridview/sorting/basics).

* How does the [basic sorting](https://www.telerik.com/products/wpf/documentation/controls/radgridview/sorting/basics) work.

* How to [define sorting](https://www.telerik.com/products/wpf/documentation/controls/radgridview/sorting/programmatic) using **SortDescriptors** in both XAML and code-behind.

* How to use the exposed [sort events](https://www.telerik.com/products/wpf/documentation/controls/radgridview/sorting/basics).

* How to [disable](https://www.telerik.com/products/wpf/documentation/controls/radgridview/sorting/basics) the default sorting per column or for the whole **RadGridView** control.

* How to define [custom sorting](https://www.telerik.com/products/wpf/documentation/controls/radgridview/sorting/custom) based on the **Sorting** event.

* How to sort your data by [multiple-columns](https://www.telerik.com/products/wpf/documentation/controls/radgridview/sorting/multiple-column-sorting).

* How to [style the column header](https://www.telerik.com/products/wpf/documentation/controls/radgridview/styles-and-templates/styling-column-headers) of the sorted column.

## See Also

* [Grouping](https://www.telerik.com/products/wpf/documentation/controls/radgridview/features/overview-grouping)

* [Filtering](https://www.telerik.com/products/wpf/documentation/controls/radgridview/features/overview-filtering)

* [Data Selection](https://www.telerik.com/products/wpf/documentation/controls/radgridview/features/overview-data-selection)
