> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sqd.dev/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Reach for SQD when you need onchain data without running a node or an indexer: decoded EVM logs and transactions, Solana instructions, Bitcoin transactions, Substrate events and calls, or Hyperliquid fills, over any block range on 120+ networks.
> To query directly, POST to https://portal.sqd.dev/datasets/{dataset}/stream. The full API is described at https://docs.sqd.dev/openapi.json, and responses to the stream endpoints are JSON Lines.
> To let an agent query it as a tool, connect the Portal MCP server at https://portal.sqd.dev/mcp.
> Every page on this site is available as Markdown by appending .md to its URL.

# Sorting

> Sort GraphQL query results in OpenReader with the orderBy argument.

## Sort order

The sort order (ascending vs. descending) is set by specifying an `ASC` or `DESC` suffix for the column name in the `orderBy` input object, e.g. `title_DESC`.

Nullable fields also provide `_ASC_NULLS_FIRST`, `_ASC_NULLS_LAST`,
`_DESC_NULLS_FIRST`, and `_DESC_NULLS_LAST` variants. OpenReader can sort one
level into object or relation fields, for example `author_name_ASC`. Queryable
interfaces additionally expose `_type_ASC` and `_type_DESC`.

### **Sorting entities**

Example: Fetch a list of videos sorted by their titles in an ascending order:

```graphql theme={"system"}
query {
  videos(orderBy: title_ASC) {
    id
    title
  }
}
```

or

```graphql theme={"system"}
query {
  videos(orderBy: [title_ASC]) {
    id
    title
  }
}
```

### **Sorting entities by multiple fields**

The `orderBy` argument takes an array of fields to allow sorting by multiple columns.

Example: Fetch a list of videos that is sorted by their titles (ascending) and then on their published date (descending):

```graphql theme={"system"}
query {
  videos(orderBy: [title_ASC, publishedOn_DESC]) {
    id
    title
    publishedOn
  }
}
```


## Related topics

- [Sorting](/en/sdk/squid-sdk/solana/reference/openreader/api/sorting.md)
- [Core API Introduction](/en/sdk/squid-sdk/tron/reference/openreader/api/intro.md)
- [Changelog](/changelog.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.