---
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://mixpeek.com/.well-known/search?q={query}"
  method: GET
  documentation: "https://mixpeek.com/llms.txt"
---

1.  [](/)
2.  [Capabilities](/capabilities)
3.  Attribute Sorting

Back to Capabilities

# Attribute Sorting

Sort results by payload field values with ascending or descending order

[Try Sorting](/start)

### Why do anything?

Search results need ordering beyond relevance. Users want to sort by date, price, rating, etc.

### Why now?

Real applications need multiple sorting options for user control.

### Why this feature?

Sort documents by any payload field with configurable order (asc/desc) and null handling.

## How It Works

Sort by attribute provides deterministic ordering based on payload field values.

1

#### Field Extraction

Extract sort field from document payloads

2

#### Sorting

Apply sorting algorithm with configured order

3

#### Null Handling

Position null values according to config

### Why This Approach

Simple, fast sorting for structured fields. Complements relevance-based ranking.

## Where This Is Used

[

E-commerce

#### Product Price Sorting



](/solutions/ecommerce)

## Integration

PythonAPI

retriever = client.retrievers.create(stages=\[{"type": "sort\_attribute", "field": "price"}\])

[View Documentation](https://mixpeek.com/docs/retrieval/retrievers)

## Related Capabilities

[

often combined

#### Attribute Filter

Filter then sort



](/capabilities/attribute-filter)