def format_ordinal(n):
    """
    Format an ordinal, like 1st, 2nd, 3rd...

    Not tested with large numbers of negative numbers!
    """
    if 10 <= n % 100 < 20:
        return str(n) + 'th'
    else:
        return str(n) + {(1): 'st', (2): 'nd', (3): 'rd'}.get(n % 10, 'th')
