The AutoTechJobs API allows you to sort collection results according to various criteria. Sorting can be combined with filtering and pagination to help you efficiently retrieve and organize data.
Sorting is controlled using the sort query parameter. You can specify both the field to sort by and the direction (ascending or descending).
GET /v1/jobs?sort=posted_at:descThe sort parameter uses the following syntax:
sort=field:directionWhere:
field is the name of the field to sort bydirection is either asc (ascending) or desc (descending)If no direction is specified, ascending order is used by default:
GET /v1/jobs?sort=title You can sort by multiple fields by separating them with commas. The sorting will be applied in the order specified.
GET /v1/jobs?sort=location,salary:desc The following tables list the sortable fields for each resource type:
| Field | Description | Default Direction |
|---|---|---|
title | Job title | asc |
posted_at | Posting date | desc |
location | Job location | asc |
salary | Job salary | desc |
company_name | Company name | asc |
application_count | Number of applications | desc |
| Field | Description | Default Direction |
|---|---|---|
name | Company name | asc |
location | Company location | asc |
created_at | Account creation date | desc |
open_positions | Number of open positions | desc |
employee_count | Number of employees | desc |
GET /v1/jobs?sort=posted_at:descGET /v1/jobs?location=manchester&sort=salary:descGET /v1/employers?sort=open_positions:descIf no sort parameter is provided, each endpoint has its own default sorting:
/jobs: sorted by posted_at:desc (newest first)/employers: sorted by name:asc (alphabetically)/candidates: sorted by last_active:desc (most recently active first)When sorting is applied, the response format remains the same as the standard endpoint response, but the order of resources is changed. The meta section of the response includes information about the applied sorting.
{
"data": [ ... ], // Sorted results
"meta": {
"sort": {
"fields": ["salary"],
"directions": ["desc"]
},
"pagination": { ... }
}
}For more information on combining sorting with filtering, see the Filtering documentation.
To learn about paginating sorted results, see the Pagination documentation.