> For the complete documentation index, see [llms.txt](https://sandyzeng.gitbook.io/kql/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sandyzeng.gitbook.io/kql/kql-quick-guide/my-favorites/sort-by.md).

# sort by

Sort the rows of the input table into order by one or more columns. Default is **descending order**

### 🦄 Example: Intune audit log for the past 7 days

Sort by TimeGenerated column in ascending order.

```
IntuneAuditLogs 
| where TimeGenerated > ago (7d)
| sort by TimeGenerated asc 
```

<figure><img src="/files/0IsumsVuSrxMyPxRew74" alt=""><figcaption></figcaption></figure>
