# Angular TreeList Sorting Basics

The sorting functionality enables you to arrange the data by single or multiple fields in ascending or descending order.

Enable the sorting feature by using two methods:

* [Automatic Data Processing](https://www.telerik.com/kendo-angular-ui/components/treelist/sorting/basics#automatic-data-processing)—Implement sorting (or other [data operations](https://www.telerik.com/kendo-angular-ui/components/treelist/data-operations)) with less code.
* [Manual Sorting](https://www.telerik.com/kendo-angular-ui/components/treelist/sorting/manual-sorting)—Provides more control when implementing the sorting feature.

## Automatic Data Processing

When you use the built-in binding directives for flat and hierarchical data, the TreeList performs the sorting automatically for you.

> Further details on how the data binding directives work under the hood are available in the [data operations with the built-in directives](https://www.telerik.com/kendo-angular-ui/components/treelist/data-operations#automatic-data-processing) documentation section.

To enable sorting:

1. Provide the collection to the built-in [`kendoTreeListFlatBinding`](https://www.telerik.com/kendo-angular-ui/components/treelist/api/flatbindingdirective) or [`kendoTreeListHierarchyBinding`](https://www.telerik.com/kendo-angular-ui/components/treelist/api/hierarchybindingdirective) directive depending on your data type.
2. Set the [`sortable`](https://www.telerik.com/kendo-angular-ui/components/treelist/api/treelistcomponent#sortable) property to `true`.
3. (Optional) Set the [`sort`](https://www.telerik.com/kendo-angular-ui/components/treelist/api/treelistcomponent#sort) property to a collection of [`SortDescriptor`](https://www.telerik.com/kendo-angular-ui/components/data-query/api/sortdescriptor) objects. This allows you to sort the data by specific criteria during the initialization of the TreeList.

```html
<kendo-treelist
    [kendoTreeListFlatBinding]="data"
    idField="id"
    parentIdField="parentId"
    [sortable]="true">
    <kendo-treelist-column field="name"></kendo-treelist-column>
</kendo-treelist>
```

The following example demonstrates the TreeList sorting functionality when the `kendoTreeListFlatBinding` directive is applied.

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

## Suggested Links

* [Manual Sorting](https://www.telerik.com/kendo-angular-ui/components/treelist/sorting/manual-sorting)
* [Multi-Column Sorting](https://www.telerik.com/kendo-angular-ui/components/treelist/sorting/multi-sort)
* [Custom Sorting](https://www.telerik.com/kendo-angular-ui/components/treelist/sorting/manual-sorting#custom-sorting)
* [API Reference of the TreeListComponent](https://www.telerik.com/kendo-angular-ui/components/treelist/api/treelistcomponent)
* [API Index of the TreeList](https://www.telerik.com/kendo-angular-ui/components/treelist/api)
