def yield_matching_vectors(vectors, search_cls_list):
    """
    Yields all possible vectors that connect all of the given classes.
    The result is sorted by the position of the primary class, and
    the vector length.
    """
    for vector in vectors:
        for target_cls in search_cls_list:
            if target_cls not in vector:
                break
        else:
            yield vector
