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

# ORDER BY

> Sort the results by one or more columns

`ORDER BY` sorts the results. Name a column and a direction: `DESC` for largest first, or `ASC` for smallest first.

```sql theme={null}
FROM sales
  SHOW total_revenue, units_sold
  GROUP BY vendor
  ORDER BY total_revenue DESC
```

You can sort by more than one column. Later keys break ties in the earlier ones.

```sql theme={null}
FROM sales
  SHOW total_revenue, units_sold
  GROUP BY vendor
  ORDER BY total_revenue DESC, units_sold ASC
```

Sorting is what makes [LIMIT](/stockfulql/syntax/limit) meaningful, since it decides which rows the cap keeps. It also sets the order that [WITH CUMULATIVE\_VALUES](/stockfulql/syntax/with) accumulates over.
