'Efficiently apply new order of generators.
Examples
>>> from sympy import Poly
>>> from sympy.abc import x, y
>>> Poly(x**2 + x*y**2, x, y).reorder(y, x)
Poly(y**2*x + x**2, y, x, domain=\'ZZ\')'

def reorder(f, *gens, **args):

    opt = options.Options((), args)
    if (not gens):
        gens = _sort_gens(f.gens, opt=opt)
    elif (set(f.gens) != set(gens)):
        raise PolynomialError('generators    list    can    differ    only    up    to    order    of    elements')
    rep = dict(list(zip(*_dict_reorder(f.rep.to_dict(), f.gens, gens))))
    return f.per(DMP(rep, f.rep.dom, (len(gens) - 1)), gens=gens)
