<aside> <img src="https://s3-us-west-2.amazonaws.com/secure.notion-static.com/a5a1e3ce-00fa-46e4-9a75-58c2aed9e8ce/Notion_Fundamentals_with_Thomas_Frank_-_Avatar_2021.png" alt="https://s3-us-west-2.amazonaws.com/secure.notion-static.com/a5a1e3ce-00fa-46e4-9a75-58c2aed9e8ce/Notion_Fundamentals_with_Thomas_Frank_-_Avatar_2021.png" width="40px" /> This example database shows how rows can be sorted using both true numeric criteria (e.g. 100 before 2) and string sorting (i.e. 1, 1A, 1B, 2) using a single formula property.

Created by Thomas Frank | Learn Notion Formulas | Notion Basics | Templates | Twitter

</aside>

Robust Number Sorting

// Compressed
slice("0000000000", 0, 10 - length(replace(prop("Name"), "^\\\\D*(\\\\d+).*", "$1"))) + replace(replaceAll(prop("Name"), "_", ""), "^\\\\D*(\\\\b\\\\d+\\\\w?\\\\b).*", "$1")

// Expanded
slice(
    "0000000000", 
    0, 
    10 - length(
        replace(
            prop("Name"), 
            "^\\\\D*(\\\\d+).*", 
            "$1"
        )
    )
) + replace(
    replaceAll(
        prop("Name"), 
        "_", 
        ""
    ), 
    "^\\\\D*(\\\\b\\\\d+\\\\w?\\\\b).*", 
    "$1"
)

© Thomas Frank