> 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="https://3533425259-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fbx8yn20QqNJtsVaH9CY7%2Fuploads%2F0kbivIZ6oYwPmuySUYbr%2Fimage.png?alt=media&amp;token=439fa90e-1d37-434d-980f-b708444ab378" alt=""><figcaption></figcaption></figure>
