(*iterables, **kwargs)
Helper for ``collate()``, called when the user is using the ``reverse``
    or ``key`` keyword arguments on Python versions below 3.5.
Helper for ``collate()``, called when the user is using the ``reverse``
    or ``key`` keyword arguments on Python versions below 3.5.
Helper for collate () called when the user is using the reverse or key keyword arguments on Python versions below 3 . 5 .
def _collate(*iterables, **kwargs):
    """Helper for ``collate()``, called when the user is using the ``reverse``
    or ``key`` keyword arguments on Python versions below 3.5.

    """
    key = kwargs.pop('key', lambda a: a)
    reverse = kwargs.pop('reverse', False)

    min_or_max = partial(max if reverse else min, key=itemgetter(0))
    peekables = [peekable(it) for it in iterables]
    peekables = [p for p in peekables if p]  # Kill empties.
    while peekables:
        _, p = min_or_max((key(p.peek()), p) for p in peekables)
        yield next(p)
        peekables = [x for x in peekables if x]
def _collate ( * iterables , * * kwargs ) : key = kwargs . pop ( 'key' , lambda a : a ) reverse = kwargs . pop ( 'reverse' , False ) min_or_max = partial ( max if reverse else min , key = itemgetter ( 0 ) ) peekables = [ peekable ( it ) for it in iterables ] peekables = [ p for p in peekables if p ] # Kill empties. while peekables : _ , p = min_or_max ( ( key ( p . peek ( ) ) , p ) for p in peekables ) yield next ( p ) peekables = [ x for x in peekables if x ]