# Sorting

The Kendo UI Gantt for Angular enables you to sort single or multiple data fields.

## Getting Started

To enable sorting, set the [`sortable`](https://www.telerik.com/kendo-angular-ui-develop/components/gantt/api/ganttcomponent#sortable) option of the Gantt to `true`.

Clicking a column header sorts the content by a column field. A second click toggles the sort direction; a third one reverts to the unsorted state.

The following example demonstrates how to enable basic sorting in the Gantt by setting the `sortable` option to `true`.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/gantt/sorting/basic/source.txt)

## Sorting by Multiple Fields

The Gantt supports sorting by several fields. The Gantt indicates displays a number next to the sorting indicator to indicate the sorting order.

To enable multiple-column sorting, set the [`sortable`](https://www.telerik.com/kendo-angular-ui-develop/components/gantt/api/ganttcomponent#sortable) option to a [`SortSettings`](https://www.telerik.com/kendo-angular-ui-develop/components/gantt/api/sortsettings) object which contains `{ mode: 'multiple' }`.

The following example demonstrates how to enable multiple-column sorting in the Gantt by setting the `sortable` option to `{ mode: 'multiple' }`.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/gantt/sorting/multiple/source.txt)

## Setting the Initial Sort Order

To set the initial sorting configuration, bind the [`sort`](https://www.telerik.com/kendo-angular-ui-develop/components/gantt/api/ganttcomponent#sort) property of the TreeList to a collection of sort descriptors. For more information on how to process data collections, refer to the article on the [process helpers for bulk data operations](https://www.telerik.com/kendo-angular-ui-develop/components/data-query/bulk-operations#sorting).

You can set the sorting direction of each field to ascending or descending by configuring the `dir` property of the [`SortDescriptor`](https://www.telerik.com/kendo-angular-ui-develop/components/data-query/api/sortdescriptor) to `asc` or `desc` respectively. If `dir` is not set, the descriptor will not be processed.

The following example demonstrates how to set a sortable Gantt with initially applied sorting configuration.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/gantt/sorting/initial/source.txt)

## Disabling the Unsorted State

The Gantt allows the user to remove a field from the sort order after cycling the sort direction. To disable this behavior and ensure that the fields are always sorted, set the [`sortable`](https://www.telerik.com/kendo-angular-ui-develop/components/gantt/api/ganttcomponent#sortable) option to a [`SortSettings`](https://www.telerik.com/kendo-angular-ui-develop/components/gantt/api/sortsettings) object which contains `{ allowUnsort: false }`

The following example demonstrates how to disable the unsorted state in the Gantt by configuring the `sortable` option with `{ allowUnsort: false }`.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/gantt/sorting/unsort/source.txt)

## Suggested Links

* [Data Query Overview](https://www.telerik.com/kendo-angular-ui-develop/components/data-query)
* [API Reference of the GanttComponent](https://www.telerik.com/kendo-angular-ui-develop/components/gantt/api/ganttcomponent)
* [API Index of the Gantt](https://www.telerik.com/kendo-angular-ui-develop/components/gantt/api)
