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

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback:

POST https://docs.omni.co/feedback

```json
{
  "path": "/modeling/query-views/parameters/sorts",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.

</AgentInstructions>

# sorts

> Defines the field(s) that the query is sorted by.

## Syntax

```yaml theme={null}
query:
  sorts:
    - field: <view_name.field_name>
      desc: <true_or_false>
```

## Properties

<ParamField path="query" type="object[]">
  An object containing the individual parameters that make up a query view's query definition.

  <Expandable title="query properties" defaultOpen="true">
    <ParamField path="sorts" type="array[object]">
      An array of sort definitions. Each sort includes a `field` parameter and optionally a `desc` parameter for descending order.
    </ParamField>

    <Expandable title="sorts properties" defaultOpen="true">
      <ParamField path="field" type="string">
        The field to sort by, specified as `view_name.field_name`.
      </ParamField>

      <ParamField path="desc" type="boolean" default="false">
        If `true`, sort in descending order. Defaults to `false` for ascending order.
      </ParamField>
    </Expandable>
  </Expandable>
</ParamField>

## Examples

```yaml title="Sort by created_at (asc) & age (desc)" theme={null}
query:
  fields:
    users.age: age
    users.created_at[year]: created_at_year
  base_view: users
  sorts:
    - field: users.created_at[year]
    - field: users.age
      desc: true
```
