Sorting allows you to control the order in which items appear in list responses. This is useful for prioritizing results by attributes such as names, identifiers, or creation timestamps.
Default Sorting
If no explicit sort order is provided, results are sorted by the entityโs
id
in ascending order.
There are currently two places where sorting can be applied:
- List Endpoints
- Search Endpoints
List Endpoints: Simple Sorting
The list endpoints with paginated responses (GET /api/units
, etc.) allow basic sorting upon a single, primitive property of the entity in ascending (default) or descending order via query parameters.
Example: GET /api/units?SortByAttributeName=number&AscendingOrder=false
Search Endpoints: Complex Sorting
These search endpoints allow more complex sorting for their paginated list responses (POST /api/units/search
, etc.). The sorting configuration is provided via the request body (body.orderBy
property). For the following features, ascending is also the default.
Direct Entity properties
This is the same capability as the simple sorting.
Example:
POST /api/units/search
{
"orderBy": [
"number"
]
}
{
"orderBy": [
"number asc"
]
}
{
"orderBy": [
"number desc"
]
}
Output: Paginated list of Units
sorted based on the property number
in ascending/descending order.
Nested Sorting
With nested sorting, we apply more complex sorting in cases where entities have matching values for given sorting parameters.
Example:
POST /api/units/search
{
"orderBy": [
"number asc",
"entranceId desc"
]
}
Output: Paginated list of Units
sorted based on the property number
in ascending order. Units with the same number
are then sorted based on their entranceId
in descending order.
Related entities
Not Available Yet!
Sorting based on related entities is not supported yet.
Example: Sort
POST /api/entities/search
based on the address of the the relatedProperty
.