I read this asmeurer's answer. He said that i can define a funtion to order my expression.How can i do that? I don't have enough reputation to comment in the answer.I want to make a function that sort the expression by symbol and it's degree like this:
...exp=m*x**3 + 3*m**2*x + x**2 + 1
...print(sort(exp,x))
m*x**3 + x**2 + 3*m**2*x + 1
...print(sort(exp,m))
3*x*m**2 + 3*x**3*m + x**2 + 1