import itertools


def is_sorted(iterable, *, key=None, reverse=False, strict=False):
    """Returns true if iterable is sorted

    Parameters
    ----------
    iterable : iterable
        The iterable to check for sorted-ness.
    key : x -> y, optional
        Apply mapping function key to iterable prior to checking. This can be
        done before calling, but this ensures identical calls as sorted.
    reverse : bool, optional
    `key` and `reverse` function as they for `sorted`"""
    if key is not None:
        iterable = map(key, iterable)

    ait, bit = itertools.tee(iterable)
    next(bit, None)  # Don't throw error if empty

    if strict and reverse: # pylint: disable=no-else-return
        return all(a > b for a, b in zip(ait, bit))
    elif reverse:
        return all(a >= b for a, b in zip(ait, bit))
    elif strict:
        return all(a < b for a, b in zip(ait, bit))
    else:
        return all(a <= b for a, b in zip(ait, bit))