> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://contentful.com/developers/docs/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://contentful.com/developers/docs/_mcp/server.

# Collection Order

The GraphQL Content API allows users to specify the fields and direction to sort on root collection queries.

For example, for the type `FriendlyUser` structured in the following way:

```graphql
type FriendlyUser {
  sys: Sys
  name: String
  age: Int
}
```

The schema defines the following order input enum type:

```graphql
enum FriendlyUserOrder {
  name_ASC
  name_DESC
  age_ASC
  age_DESC
  sys_id_ASC
  sys_id_DESC
}
```

Order enum values can be passed to collection queries of their corresponding type to sort the result set.

For example, to find the oldest `FriendlyUser`, write the following query:

```graphql
query {
  friendlyUserCollection(order: [age_DESC], limit: 1) {
    items {
      name
    }
  }
}
```

Collections can be sorted by multiple fields, each of them with a direction information.

For example, to order `FriendlyUser`s by their age (descending) first and for items with same age it should sort by name (ascending), write the following query:

```graphql
query {
  friendlyUserCollection(order: [age_DESC, name_ASC]) {
    items {
      name
      age
    }
  }
}
```

You can order collections in `linkedFrom`:

```graphql
query {
  catCollection {
    items {
      name
      linkedFrom {
        friendlyUserCollection(order: [age_DESC, name_ASC]) {
          items {
            firstName
          }
        }
      }
    }
  }
}
```

> **Info**
>
> **Note:** You cannot order the `entryCollection` field.

```graphql
query {
  catCollection {
    items {
      name
      linkedFrom {
        friendlyUserCollection(order: [age_DESC, name_ASC]) {
          items {
            firstName
          }
          entryCollection {
            __typename
          }
        }
      }
    }
  }
}
```

## Limitations

It is not possible to order on fields of type `Link`, `Text`, `Location`, `Object`, or `RichText`.

> **Info**
>
> **Note:** When using `allowedLocales`, the order argument that you have passed will not be applied to the fallback values, which might make the result seem to be unordered.