Given a polynomial, lets say for example $f(x,y) = (1+x+y)^2 = 1+2x+x^2+2y+2xy+y^2$, I'd like to be able to order the terms of the polynomial by total degree, either in increasing or decreasing order (and if alphabetical order can be taken into account within terms of the same total order, then that would be great, but not necessary).
I'd like a function to take in $1+2x+x^2+2y+2xy+y^2$ and return $(1) + (2x + 2y) + (x^2 + 2xy + y^2)$, or in reverse order (and not necessarily with parenthesis, but that would be nice to work with.
I've tried various commands using Collect[], and MonomialList[], and while MonomialList[f(x,y),{x,y},"DegreeLexicographic"] gives a list of the terms in the order I want, I would like the full expression.
Total[MonomialList[f(x,y),{x,y},"DegreeLexicographic"]will sum the list. $\endgroup$Total[HoldForm /@ CoefficientList[f[t*x, t*y], t]]$\endgroup$