import re


def map_post_version_sort_to_number(stem: str) -> int:
    """
    Maps the post version string (e.g. "post1" in "1.27.4.post1") to a
    number. This defines the sorting of the releases.
    """
    if re.match(r".*rc\d+", stem):
        return 0
    if re.match(r".*\.post\d+", stem):
        return 2
    return 1