# Sorting

## Sort Values in Decision Tables

The sorting feature helps you rearrange the rows of your table in either ascending or descending order based on the values in a specific column.

## How to Apply Sorting

<figure><img src="https://437457296-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MN4F4-qybg8XDATvios%2Fuploads%2F4HG3bDtOvyzWTrS7JEDh%2Fsort.png?alt=media&#x26;token=758c3c02-4cdd-4d0d-a918-d9140815c86b" alt="" width="557"><figcaption></figcaption></figure>

1. **Access Sorting**: Click the arrow icon in the header of the column you want to sort, then select **Sorting**.
2. **Choose Sort Order**:
   * **Sort by A-Z** (ascending)
   * **Sort by Z-A** (descending)

## Managing Sorting

* Only one column can be sorted at a time. Applying sorting to another column will reset the sorting of the previous one.
* When a column is actively sorted, a sorting icon will appear in the column header.
* To change the sorting direction, click the arrow icon in the column header, select **Sorting**, and choose the desired order.
* To remove sorting, click the arrow icon in the header, select **Sorting**, and choose **Reset sorting**.

<figure><img src="https://437457296-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MN4F4-qybg8XDATvios%2Fuploads%2FK84td9Zpu5sYVcOhHim5%2Freset%20sorting.png?alt=media&#x26;token=6bd8c9d5-dab3-4ff1-911b-ec8828e41659" alt=""><figcaption></figcaption></figure>

## Sorting Rules

When a column contains multiple data types, sorting follows specific rules. Here’s how DecisionRules handles sorting:

### Descending Order

1. **Text**: Zz-Aa
2. **Numbers**: 9-0
3. **Operator**: `ELSE`
4. **Number fields**: (e.g., `BTW`)
5. **Dates**
6. **Date fields**: (e.g., `BTW`)
7. **Functions**
8. **Operator**: `ANY`

### Ascending Order

1. **Operator**: `ELSE`
2. **Numbers**: 0-9
3. **Text**: aA-zZ
4. **Number fields**: (e.g., `BTW`)
5. **Dates**
6. **Date fields**: (e.g., `BTW`)
7. **Functions**
8. **Operator**: `ANY`

<div><figure><img src="https://437457296-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MN4F4-qybg8XDATvios%2Fuploads%2F5thUptnTcjrbJPT0AuaO%2Fascending%20sorting.png?alt=media&#x26;token=5de2d0b1-6da2-4fd9-8eaa-ceffe5ea87a7" alt="" width="337"><figcaption><p>Example of Sort by A-Z option</p></figcaption></figure> <figure><img src="https://437457296-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MN4F4-qybg8XDATvios%2Fuploads%2FtqU8TvHZZwHKjicRtUd7%2Fdesc%20order.png?alt=media&#x26;token=2f026235-2d93-4310-a878-f6657dfa2b92" alt="" width="339"><figcaption><p>Example of Sort by Z-A option</p></figcaption></figure></div>
