# Sorting

## Data Endpoints

The `/data` endpoint provides the ability to allow sorting by using the `sort` query parameter:

* `sort` : Comma separated list of fields that are being preceded by `"+"` to display in ascending order, or `"-"` for
descending order. For example: `sort=+opportunity_value,-opportunity_id`


Note that if no +/- prefix is provided, the results will be sorted in ascending order (+) by default.

Note also, the fields used for sorting must exist for the requested record.

## Schema Endpoints

Schema endpoints also provide the ability to sort their results by leveraging the `sort` query parameter as follows:

* Multi-field sorting is not allowed, i.e. it is not possible to sort by more than one field.
* Fields in the `sort` query param should be prefixed with a ‘+’ for ascending order or ‘-’ for descending order.
* If no +/- prefix is provided, the results will be sorted in ascending order (+).
* The results will be sorted as case insensitive.


Some examples are:

* Get all Knowledge Models: `/knowledge-models?sort=+id`
* Get all Filters for a Knowledge Model: `/knowledge-models/{km_id}/filters?sort=-name`
* Get all Records for a Knowledge Model: `/knowledge-models/{km_id}/records?sort=id`
* Get all KPIs for a Knowledge Model: `/knowledge-models/{km_id}/kpis?sort=id`
* Get all Fields (attributes, augmented attributes and flags) for a Record of a Knowledge Model: `/knowledge-models/{km_id}/records/{record_id}?sort=-id`


pageSize refers to the events returned in the page.
total refers to the total events still at the API.
content events as raw JSON.