Skip to main content
Deprecated as of version 2025-09-03This page describes the API for versions up to and including 2022-06-28. In the new 2025-09-03 version, the concepts of databases and data sources were split up, as described in Upgrading to 2025-09-03.Refer to the new page instead:
A sort is a condition used to order the entries returned from a database query. A database query can be sorted by a property and/or timestamp and in a given direction. For example, a library database can be sorted by the “Name of a book” (i.e. property) and in ascending (i.e. direction). Here is an example of a sort on a database property.
If you’re using the Notion SDK for JavaScript, you can apply this sorting property to your query like so:
Database queries can also be sorted by two or more properties, which is formally called a nested sort. The sort object listed first in the nested sort list takes precedence. Here is an example of a nested sort.
In this example, the database query will first be sorted by “Food group” and the set with the same food group is then sorted by “Name”.

Sort object

Property value sort

This sort orders the database query by a particular property. The sort object must contain the following properties:

Entry timestamp sort

This sort orders the database query by the timestamp associated with a database entry. The sort object must contain the following properties: