Question: Sorting monomials by total degree and lexicographic order?

Hello,

I need to sort a list of monomials in a custom order based on two criteria:

  1. Increasing total degree (e.g., x<x^2)

  2. Lexicographic order within the same degree, using a specified variable order such as x<y<z.

For example, given the list:

L := [z^2, y*z, x*z, z, y^2, x*y, y, x^2, x, 1] 

and the variable order (which can be changed by the user):

vars := [x, y, z]; 

I would like the output to be:

[1, x, y, z, x^2, x*x, x*y, x*z, y^2, y*z, z^2]

Is there a built-in function or a recommended way to achieve this in Maple?

Thank you!

Please Wait...