Sorting Direction — Ascending and Descending Conventions
DodaTech
Updated 2026-06-28
1 min read
In this tutorial, you will learn about Sorting Direction. We cover key concepts, practical examples, and best practices to help you master this topic.
Sorting direction tells the API whether to sort in ascending (A-Z, 0-9) or descending (Z-A, 9-0) order using consistent parameter conventions.
Direction Indicators
# Common conventions:
GET /api/users?sort=name&direction=desc
GET /api/users?sort=-name # minus prefix = descending
GET /api/users?sort=name:desc # colon suffix = descending
GET /api/users?sort=name DESC # SQL-style (not recommended)
Best Practice
Use minus prefix for descending, default to ascending:
GET /api/users?sort=name # ascending (default)
GET /api/users?sort=-name # descending
GET /api/users?sort=-created_at # descending by date
Common Mistakes
- No default direction — Requiring clients to specify direction for every sort.
- Inconsistent direction across endpoints — Different endpoints use different conventions.
- SQL-style in URLs — Using URL-encoded spaces and DESC in query strings.
Practice Questions
- What is the most common descending indicator?
- What direction is used when not specified?
- Why avoid SQL-style sort parameters?
What's Next
In the next lesson, you will learn filtering with exact match.
← Previous
Sorting Multiple Fields — Complex Sort Parameters
Next →
Filtering with Exact Match — Precise Field Value Filtering
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro