def ordered_intersect(*sets):
 common = frozenset.intersection(*map(frozenset, sets))
 return (x for x in unique(concat(sets)) if (x in common))

def ordered_intersect ( * sets ) : common = frozenset . intersection ( * map ( frozenset , sets ) ) return ( x for x in unique ( concat ( sets ) ) if ( x in common ) )
set intersection of two sequences that preserves order .