# ORDER BY keyword in CQL (Confluence): fields and examples

URL: https://goingstellar.ro/reference/cql/order-by/

ORDER BY sorts the results of a CQL query. Name one field or several, each with asc or desc. It goes at the end of the query, after every filter clause.

## Syntax

```
query ORDER BY field [asc|desc]
query order by field1 desc, field2 asc
```

## Arguments

- `field` (optional: yes): A field that supports ordering, for example created, lastmodified or title.
- `asc / desc` (optional: no): Sort direction. If you leave it out, the field's own default order is used.

## Works with

- Operators: it sorts the results of any query. It is not a filter.
- Functions: none.
- Not with: space, label, text, ancestor, parent, macro, fileExtension, pageStatus and subtype (see the pitfalls). Sorting worked on created, lastmodified, title, id, type, creator, contributor, owner, watcher, favourite, mention, content and creator.fullname.

## Examples

```
type = page and space = SD order by lastmodified desc
```

Puts the most recently changed pages at the top, for a stale-page review in reverse. Run on Confluence Cloud on 2026-11-29.

```
type = page and space = SD order by title asc
```

Gives an alphabetical page index for a space. Run on Confluence Cloud on 2026-11-29.

```
type = page and space = SD order by created desc, title asc
```

Sorts by creation date, newest first, and uses the title to order pages made at the same time. Run on Confluence Cloud on 2026-11-29.

```
type = attachment order by created desc
```

Lists the latest uploaded files first. Run on Confluence Cloud on 2026-11-29.

```
type = page and space = SD ORDER BY title ASC
```

Same as the lowercase form. The keyword and the direction are not case sensitive. Run on Confluence Cloud on 2026-11-29.

## Pitfalls

- The documentation example `creator = "..." order by space, title asc` fails. `order by space` returns HTTP 501 "space does not support ordering" (checked on Confluence Cloud, November 2026). Sort by title or date instead.
- Several fields fail in different ways. `label`, `text`, `ancestor`, `parent` and `macro` all give "Could not parse cql", which looks the same as a misspelt field. `fileExtension`, `pageStatus` and `subtype` give HTTP 500 "supports ordering but does not implement buildOrder".
- ORDER BY needs a query before it. A query that is only `order by title asc` fails with "Could not parse cql". Only `asc` and `desc` are accepted; `descending` and a trailing comma fail the same way.
- ORDER BY does not take a limit. Paging is a parameter of the REST call, not part of the query.

## Related

- [AND](https://goingstellar.ro/reference/cql/and-keyword/)
- [created](https://goingstellar.ro/reference/cql/created-field/)
- [lastmodified](https://goingstellar.ro/reference/cql/lastmodified-field/)
- [title](https://goingstellar.ro/reference/cql/title-field/)
- [space](https://goingstellar.ro/reference/cql/space-field/)
- [Reserved characters and words](https://goingstellar.ro/reference/cql/reserved-words/)

## Sources

- [CQL keywords (Atlassian Developer, Confluence Cloud)](https://developer.atlassian.com/cloud/confluence/cql-keywords/)

