Allow to specify the generators when building monomial_key.

This allows to obtain a sort key that can be directly applied to sort `Expr` instances; it casts `Expr` into `Poly` with the given generators and then applies the chosen ordering.