---
title: "Sorting"
manual: "TCA_API"
version: "2.2"
permalink: "https://docs.typo3.org/permalink/maikschneider/tca-api:sorting@2.2"
source: "Configuration/Sorting.rst"
rendered: "2026-10-12T13:17:40+00:00"
---

# Sorting {#sorting}

The `order` section configures which columns can be used for sorting and the
default sort order.

## Configuration {#configuration}

```php
'order' => [
    'allowed' => ['title', 'uid'],       // columns allowed for sorting
    'default' => ['uid' => 'asc'],       // fallback when no order is requested
],
```

| Key | Description |
| --- | --- |
| `allowed` | Array of column names that the client is permitted to sort by. |
| `default` | Associative array of `column => direction` pairs used when the client does not provide an `order` parameter. Direction can be `asc` or `desc`. |

## Usage {#usage}

Sorting is controlled via the `order` query parameter:

```text
GET /_api/articles?order[title]=asc
GET /_api/articles?order[uid]=desc
```

Once `allowed` is declared, only the columns listed in it are accepted.
Requesting any other column returns `400 Bad Request` naming the offending
column and the sortable set, so a typo or a forgotten `allowed` entry surfaces
instead of silently producing a differently ordered `200`.

A resource that declares no `allowed` states no restriction, so its `order`
parameters are not rejected — they fall back to `default`, or to raw database
order when there is no `default` either.
