# SortDataTable

> Sorts an entire DataTable by ascending or descending order, based on the values of a specified column.

Sorts an entire `DataTable` by ascending or descending order, based on the values of a specified column.

## Definition

**Namespace:** UiPath.Activities.System.API

**Assembly:** UiPath.System.Activities.Api (in UiPath.System.Activities.Api.dll)

## Overloads

|  |  |
| --- | --- |
| `SortDataTable(DataTable, String)` | Sorts an entire `DataTable` by ascending or descending order, based on the values of a specified column. |
| `SortDataTable(DataTable, String, SortOrder)` | Sorts an entire `DataTable` by ascending or descending order, based on the values of a specified column, while specifying the order in which the table should be sorted. |

## `SortDataTable(DataTable, String)`

Sorts an entire `DataTable` by ascending or descending order, based on the values of a specified column.

```
DataTable SortDataTable(
    DataTable dataTable,
    string columnName
)
```

`dataTable` [DataTable](https://learn.microsoft.com/dotnet/api/system.data.datatable) : The `DataTable` variable you want to sort.

`columnName` [String](https://learn.microsoft.com/dotnet/api/system.string) : The variable containing the name of the column you want to sort by.

## `SortDataTable(DataTable, String, SortOrder)`

Sorts an entire `DataTable` by ascending or descending order, based on the values of a specified column, while specifying the order in which the table should be sorted.

```
DataTable SortDataTable(
    DataTable dataTable,
    string columnName,
    SortOrder sortOrder
)
```

`dataTable` [DataTable](https://learn.microsoft.com/dotnet/api/system.data.datatable) : The `DataTable` variable you want to sort.

`columnName` [String](https://learn.microsoft.com/dotnet/api/system.string) : The variable containing the name of the column you want to sort by.

`sortOrder` `SortOrder` : The order in which the table is to be sorted.

## Return value

[DataTable](https://learn.microsoft.com/dotnet/api/system.data.datatable)

The `DataTable` variable after it has been sorted.
