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

# Sorting Results

> Learn how to order search results using the sort_by parameter

The `sort_by` parameter controls the order of your search results. You can sort by any field in ascending or descending order, and combine up to three fields for multi-level sorting.

## Quick start

Here's how to sort transactions by creation date in descending order (newest first):

```bash theme={"system"}
curl -X POST "http://YOUR_BLNK_INSTANCE_URL/search/transactions" \
  -H "X-Blnk-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "q": "*",
    "sort_by": "created_at:desc"
  }'
```

***

## Sort syntax

### Basic sorting

Sort by a single field using the format `field:direction`:

```bash theme={"system"}
# Sort by amount (lowest to highest)
"sort_by": "amount:asc"

# Sort by creation date (newest to oldest)
"sort_by": "created_at:desc"
```

### Sort directions

| Direction | Description                                   | Example           |
| :-------- | :-------------------------------------------- | :---------------- |
| `asc`     | Ascending order (A-Z, 0-9, oldest to newest)  | `amount:asc`      |
| `desc`    | Descending order (Z-A, 9-0, newest to oldest) | `created_at:desc` |

### Multi-field sorting

Combine up to three fields separated by commas. Fields are applied in order: the first field is primary, second breaks ties, third breaks remaining ties:

```bash theme={"system"}
curl -X POST "http://YOUR_BLNK_INSTANCE_URL/search/transactions" \
  -H "X-Blnk-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "q": "*",
    "sort_by": "status:asc,created_at:desc,amount:desc"
  }'
```

This sorts by:

1. **Status** (ascending) - groups by status first
2. **Created date** (descending) - within each status, newest first
3. **Amount** (descending) - for same status and date, highest amount first

***

## Common sorting patterns

<Steps>
  <Step title="Sort by creation date">
    Show the most recent records first, useful for transaction monitoring.

    ```bash theme={"system"}
    curl -X POST "http://YOUR_BLNK_INSTANCE_URL/search/transactions" \
      -H "X-Blnk-Key: YOUR_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "q": "*",
        "sort_by": "created_at:desc"
      }'
    ```
  </Step>

  <Step title="Sort by amount">
    Find the largest transactions first for financial analysis.

    ```bash theme={"system"}
    curl -X POST "http://YOUR_BLNK_INSTANCE_URL/search/transactions" \
      -H "X-Blnk-Key: YOUR_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "q": "*",
        "sort_by": "amount:desc"
      }'
    ```
  </Step>
</Steps>

***

## Best practices

* **Default to newest first**: Use `created_at:desc` for time-sensitive data like transactions.
* **Combine with filtering**: Sort filtered results for more targeted analysis.
* **Limit multi-field sorting**: Use 2-3 fields maximum to avoid complexity.

***

## Need help?

We are very happy to help you make the most of Blnk, regardless of whether it is your first time or you are switching from another tool.

To ask questions or discuss issues, please [contact us](mailto:support@blnkfinance.com) or [join our Discord community](https://discord.gg/7WNv94zPpx).

***

<Tip>
  **Tip:** Connect to Blnk Cloud to see your Core data.

  You can view your transactions, manage identities, create custom reports, invite other team members to collaborate, and perform operations on your Core — all in one dashboard.

  [Check out Blnk Cloud →](https://www.blnkfinance.com/products/cloud)
</Tip>
