Back Original

How to Randomly Sort a Table in Notion

DISCLOSURE: If you buy through affiliate links, I may earn a small commission. (disclosures)

I've been playing around with building a knowledge garden for myself now that I've moved back to Notion. It's a mix of the Zettelkasten and Digital Garden note taking methods.

I wanted a way to bubble up a random note to review semi-regularly and couldn't find a simple formula I like so here's the one I went with.

What I want in a random sort

For my sort needs, I want something where:

Notion Table Random Sort

To randomly sort a database in Notion, I created a Random property with a formula that computes a random number based on the current time and page.

Formula:

/* Create a pseudo-random number that changes on each page load (minute granularity) */
lets(
    /* Get the page ID as a stable seed */
    pageId, id(),
    /* Create a numeric value from page ID */
    idValue, toNumber(replaceAll(id(), "[a-f]", "")),
    /* Current ms - minute granularity */
    nowMs, toNumber(now()),
    /* Get the last edited time ms - minute granularity*/
    lastEditedTime, toNumber(formatDate(prop("Last Updated"), "X")),
    /* Mix the values together for pseudo-randomness */
    seedValue, (idValue * 9973) + (nowMs * 7919) + (lastEditedTime * 6421),
    /* Generate a number between 0-9999 */
    abs(seedValue % 10000)
)

The code is well commented but I'll describe it here anyway:

Next

This is a pseudo-random so I wouldn't use this in production code but it works well enough for my purposes so I'm sticking w it.

If you liked this post, you might also like: