Documents in Payload can be easily sorted by a specific Field. When querying Documents, you can pass the name of any top-level field, and the response will sort the Documents by that field in ascending order. If prefixed with a minus symbol ("-"), they will be sorted in descending order.
Because sorting is handled by the database, the field cannot be a Virtual Field. It must be stored in the database to be searchable.
To sort Documents in the Local API, you can use the sort
option in your query:
To sort in the REST API, you can use the sort
parameter in your query:
To sort in the GraphQL API, you can use the sort
parameter in your query: