Skip to main content

GridControl.SortBy(GridColumn, ColumnSortOrder, Int32) Method

Sorts data against the specified column and arranges it according to the sort order. The position of the sort condition within the GridSortInfoCollection depends on the sortedIndex parameter.

Namespace: DevExpress.Xpf.Grid

Assembly: DevExpress.Xpf.Grid.v22.1.dll

NuGet Package: DevExpress.Wpf.Grid.Core


public void SortBy(
    GridColumn column,
    ColumnSortOrder sortedOrder,
    int sortedIndex


Name Type Description
column GridColumn

A column within the GridControl.

sortedOrder ColumnSortOrder

Sort order of the specified column.

sortedIndex Int32

The index of the specified sort condition within the GridSortInfoCollection.


The GridControl allows you to sort data against multiple columns. Call the SortBy method to apply a new sort condition. The GridControl creates a new GridSortInfo object that stores sort parameters, and appends this object to the GridSortInfoCollection. The sort operation result depends on the order of the applied conditions within the collection. If the GridSortInfoCollection already contains a sort condition for the specified column, the GridControl replaces this condition with a new condition.

If the sortedIndex parameter exceeds the index of the last element within the GridSortInfoCollection, the GridControl appends the GridSortInfo object to the collection. Pass a negative value as the sortedIndex parameter to remove the applied sort condition.

Refer to the following topics for more information: Sorting in Code and Sort Data.

See Also