# Sorting

## Overview

Sorting helps organize your query results based on one or more columns in ascending (`ASC`) or descending (`DESC`) order.

## Using Sorting

In QueryDeck, you can specify sorting options by adding an `order_by` parameter to your query configuration on the left side pane.

<figure><img src="https://1803924624-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkjtTl1rn3hJ3jyoJt6ty%2Fuploads%2Fjr59SKk4MqVLDKSevTGt%2Fimage.png?alt=media&#x26;token=51b9c912-74f6-4ef7-8486-c379c6ce6841" alt=""><figcaption></figcaption></figure>

#### Example Sorting Request

To sort `customers` by `last_name` in ascending order, choose the required options in the dropdown of the pop up.

<figure><img src="https://1803924624-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkjtTl1rn3hJ3jyoJt6ty%2Fuploads%2FRIWmhje5qsclv3ZUPmlm%2Fimage.png?alt=media&#x26;token=321cfa94-cb73-4818-ac43-9460d37b4deb" alt=""><figcaption></figcaption></figure>

Then click on the 'plus' button to save and exit popup

<figure><img src="https://1803924624-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkjtTl1rn3hJ3jyoJt6ty%2Fuploads%2FycEpJmtLXec9kS9P3ViN%2Fimage.png?alt=media&#x26;token=707958f0-c2b4-4a6f-b255-bca9da5effb9" alt=""><figcaption></figcaption></figure>

copy endpoint from the top right corner

<figure><img src="https://1803924624-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkjtTl1rn3hJ3jyoJt6ty%2Fuploads%2Fwj0hZGymOMFDqufJBzZx%2Fimage.png?alt=media&#x26;token=7d452806-07ed-4b14-aea2-249158c90fa0" alt=""><figcaption></figcaption></figure>

click on the save button

<figure><img src="https://1803924624-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkjtTl1rn3hJ3jyoJt6ty%2Fuploads%2FMfJ4Qzj76g1OJWZKI880%2Fimage.png?alt=media&#x26;token=2f65a1c4-5fb4-4baf-9f74-8791a67cdfda" alt=""><figcaption></figcaption></figure>

## Testing

Goto postman, paste the endpoint and hit send

<figure><img src="https://1803924624-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkjtTl1rn3hJ3jyoJt6ty%2Fuploads%2F61NwdLsTUrKXlla9qP3c%2Fimage.png?alt=media&#x26;token=2c293c19-e63b-4475-967a-5b5dbcd4dec9" alt=""><figcaption></figcaption></figure>

you should get a response similar to the one below, where records are sorted by last name in ascending order

<figure><img src="https://1803924624-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkjtTl1rn3hJ3jyoJt6ty%2Fuploads%2F4U2UFooNYBWZPHXIkXR0%2Fimage.png?alt=media&#x26;token=796ce51d-b312-4582-b3e3-ed22db5656a4" alt=""><figcaption></figcaption></figure>
