'See the collect function in sympy.simplify'

def collect(self, syms, func=None, evaluate=True, exact=False, distribute_order_term=True):

    from sympy.simplify import collect
    return collect(self, syms, func, evaluate, exact, distribute_order_term)
