# Sort DataTable

Sorts the table by a column in ascending or descending order. Sorting follows the column's data type; for example, number columns are sorted numerically. The input table is not modified; the sorted copy is written to the `Result` output.


---

### :arrow_left:**INPUT**

| **Parameter** | **Type** | **Required** | **Description** |
|-----------|------|----------|-------------|
| `ColumnName` | `String` | ❌ No     | Name of the column to sort by. Either `ColumnName` or `ColumnIndex` must be set; if both are set, the name is used. If the column does not exist, the activity throws an error. |
| `ColumnIndex` | `Int32?` | ❌ No     | Index of the column to sort by (zero-based). Either `ColumnName` or `ColumnIndex` must be set. If it is greater than the number of columns, the activity throws an error. |
| `DataTable` | `DataTable` | ✅ Yes    | Table to sort. If empty (null), no sorting is done and `Result` is not assigned. |
| `SortType` | `SortTypes` | ❌ No     | Sort direction: `Ascending` or `Descending`. Default: `Ascending`. |


---

### :arrow_right:**OUTPUT**

| **Parameter** | **Type** | **Description** |
|-----------|------|-------------|
| `Result`  | `DataTable` | Sorted table. |