def _ordinal(n):
    """Returns the ordinal string for a given integer

    See https://stackoverflow.com/a/20007730/1307974

    Parameters
    ----------
    n : `int`
        the number to convert to ordinal

    Examples
    --------
    >>> _ordinal(11)
    '11th'
    >>> _ordinal(102)
    '102nd'
    """
    idx = int((n // 10 % 10 != 1) * (n % 10 < 4) * n % 10)
    return '{}{}'.format(n, 'tsnrhtdd'[idx::4])
