def matchby_sequence(iter1, iter2, matchfun1, matchfun2=None):

    if matchfun2 is None:
        matchfun2 = matchfun1
    groups1 = itertools.groupby(iter1, matchfun1)
    groups2 = itertools.groupby(iter2, matchfun2)

    while 1:
        key1, value1 = groups1.next()
        key2, value2 = groups2.next()

        assert key1 == key2, "input needs to be sorted in the same order."
        yield(value1, value2)
Set an array value, complex support.
dataset/ETHPy150Open CGATOxford/cgat/scripts/maq2psl.py/matchby_sequence--crossover with--dataset/ETHPy150Open OpenMDAO/OpenMDAO/openmdao/core/vec_wrapper.py/Accessor._set_arr_complex