Expressions in Maple are usually stored in the order they were created. Consequently polynomials often appear in a seemingly random order. The sort command can now be applied to sort any polynomials that appear in an expression. Univariate polynomials are sorted in descending order. Multivariate polynomials may be sorted by total degree (default) with ties broken by lexicographical order, or in pure lexicographical order. An optional argument may be given to specify the variable ordering. Example:
> a := y^3+y^2*x^2+x^3; 3 2 2 3 a := y + y x + x
> sort(a,[x,y],tdeg); 2 2 3 3 x y + x + y
> sort(a,[x,y],plex); 3 2 2 3 x + x y + y