def _direction_to_index(direction):
    """Map direction identifier to index.
    """
    directions = {-1: 0, 0: slice(None), 1: 1, '<=': 0, '<=>': slice(None), '>=': 1}

    if direction not in directions:
        raise RuntimeError('Unknown direction "{:d}".'.format(direction))

    return directions[direction]