Search

sort() | Beginner’s Guide to Notion Formula

post type
notion
tutorial
formula
status
published
author
created time
2024/10/23 12:54
description
Unlock the potential of the sort() function in Notion formulas to arrange your data efficiently! This comprehensive guide breaks down the structure of sort(), explains how it works, and provides practical examples. Learn how to sort lists in ascending or descending order to enhance your data analysis and improve your workflow in Notion.
cover image
Frame 6.png
1 more property

This is your sign to try sort()

The sort() function enables users to arrange lists in a specified order, making it easier to analyze and present data. In this blog post, we will explore the structure of the sort() function, break down how it works, and provide examples to demonstrate its utility.
For this guide, I referenced the Notion Formula documentation and added my own examples and explanations.

Summary

Name
Syntax
Description
Example
sort()
sort(list, expression?) or list.sort(expression?)
Arranges the items in a list in ascending order based on specified criteria.
sort([3, 1, 2]) → [1, 2, 3]

sort() Formula

How sort() works

The sort() function arranges the items in a list in ascending order based on specified expression or criteria. This means that smaller numbers will appear before larger numbers, earlier dates will come before later dates, and strings will be sorted alphabetically based on specific rules.
The syntax for the sort() function is as follows:
sort(list, expression?)
Notion Formula
복사
list.sort(expression?)
Notion Formula
복사
Breaking it down
list: The collection of items that you want to sort.
expression (optional): This is an optional parameter that allows you to specify a sorting criterion.

Examples of sort()

Search
example
description
formula
results
Sorting a list containing numbers. - When sorting numbers, the sort() function will organize them from smallest to largest.
sort([3, 1, 2])
Sorting a list containing dates. - The sort() function can also be used to sort dates. Earlier dates will appear before later dates.
sort([parseDate("2023-10-01"), parseDate("2023-09-15"), parseDate("2023-10-05")]
Sorting a list containg texts. - Text are sorted alphabetically.
sort(["banana", "apple", "cherry"])
Sorting a list containg texts. - Note that, sorting is case-sensitive, meaning uppercase letters will be sorted before lowercase letters.
sort(["b", "A", "B", "a"])
Sorting a list of pages provided with an expression. - This will sort the list according to the page or the property specified in the expression.
sort(prop("Tasks"), current.prop("Status")) - Let’s say there’s a relation property named Tasks containing three items: [Item 1, Item 2, Item 3]. Each item has a status property called Status: - Item 1 with status Not Started - Item 2 with status In Progress - Item 3 with status Done The sorting will follow alphabetical order based on the status property, resulting in: [Item 3, Item 2, Item 1]
Sorting a list of numbers given an expression current * -1. - The expression is applied to each item, and then sorting occurs from smallest to largest.
sort([3, 1, 2], current * -1) - First, the expression is applied to each item, resulting in values like [-3, -1, -2]. When sorted from smallest to largest, this becomes [-3, -2, -1], which maps back to [3, 2, 1].

Conclusion

Take advantage of the sort() function to enhance your Notion! Thank you for reading this tutorial! If you found it helpful, be sure to check out shop for my beautiful templates, which I am confident enough to say are a game-changer Subscribe to my newsletter and feel free to follow me on my social media for updates!
Happy Notion(ing)!
Search