# Managing Cell Range Sorting

Learn how to manage range sorting operations effortlessly in spreadsheets with Managing Cell Range Sorting in Topic Spread for WinForms. Sort textual information, arrange numbers, and order data based on colors and icons for efficient data manipulation.

## Content

Spread for WinForms allows users to manage range sorting operations without any hassle via applying sort logic on a specific cell range in a worksheet. This makes it easier and quicker to manipulate data and arrange records based on a specific sort order while working with bulk data in spreadsheets.
You can sort textual information in alphabetical order (like A-Z or Z-A), arrange numbers in ascending and descending order, sort dates from newest to oldest and vice a versa and order data based on the colors and icons in a cell range.
Users can work with cell range sorting in the following two ways:

1. [Using Sort Object of AutoFilter](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-interact-rowcol/spwin-sorting/spwin-sort-range#using-sort-object-of-autofilter)
2. [Using Sort Object in Worksheet](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-interact-rowcol/spwin-sorting/spwin-sort-range#using-sort-object-in-worksheet)

## Using Sort Object of AutoFilter

You can apply sort logic on the data in a cell range using the **Apply** method of the **ISort** interface and the **Add** method of the **ISortFields** interface.
**Example**
Refer to the following example code in order to apply sort logic on a range of cells in a spreadsheet.

```csharp
// Gets the sort column
ISort filterSort = activeSheet.AutoFilter.Sort;

// Sort column C by ascending order. 
filterSort.SortFields.Add(1);

// Set Sort Order for column B by descending
filterSort.SortFields.Add(0).Order = GrapeCity.Spreadsheet.SortOrder.Descending;
filterSort.Apply();
```

```vbnet
'Gets the sort column
Dim filterSort As ISort = activeSheet.AutoFilter.Sort

'Sort column C by ascending order
filterSort.SortFields.Add(1)

'Set Sort Order for column B by descending
filterSort.SortFields.Add(0).Order = GrapeCity.Spreadsheet.SortOrder.Descending
filterSort.Apply()
```

## Using Sort Object in Worksheet

You can add and apply sort logic on a cell range using the **Add** method of the **ISortFields** interface and the **Apply** method.

## Using Code

In order to apply the sort logic in a cell range using the sort object of the worksheet, you can use the **Apply** method of the **ISort** interface.
**Example**
Refer to the following example code to access the current filter settings in a worksheet.

```csharp
// Sort column C
worksheetSort.SortFields.Add("C1")         
// Sort range is B1:E10
worksheetSort.SetRange("B1:E10");
worksheetSort.Apply();
```

```vbnet
'Sort column C  
worksheetSort.SortFields.Add("C1")

'Sort range is B1:E10
worksheetSort.SetRange("B1:E10")
worksheetSort.Apply()
```

## See Also

[Allowing the User to Automatically Sort Rows](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-interact-rowcol/spwin-sorting/spwin-sort-setuser)
[Using Automatic Sorting](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-interact-rowcol/spwin-sorting/spwin-sort-setauto)
[Sorting Rows, Columns, or Ranges](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-interact-rowcol/spwin-sorting/spwin-sort-rowcolrange)
[Setting the Appearance of Sort Indicators](/spreadnet/docs/latest/online-win/overview/spwin-devguide/spwin-interact-rowcol/spwin-sorting/spwin-sort-indicators)