gh-35043: fix the method monomials_of_degree
<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes #1234" use "Introduce new method to
calculate 1+1"
-->
### 📚 Description
<!-- Describe your changes here in detail -->
<!-- Why is this change required? What problem does it solve? -->
<!-- If it resolves an open issue, please link to the issue here. For
example "Closes #1337" -->
Fixes #35042.
The goal of this PR is to fix two bugs of the method
`monomials_of_degree`. First, the code does not take into account the
case of weighted polynomial ring:
```
sage: P = PolynomialRing(QQ, 3, 'x,y,z', order=TermOrder('wdeglex',
[4,5,6]))
sage: P.inject_variables()
Defining x, y, z
sage: x.degree()
4
sage: P.monomials_of_degree(1)
[x, y, z]
```
Next, as pointed out by @videlec, the current list of monomial that is
returned is not sorted:
```
sage: R.<x,y,z> = ZZ[]
sage: mons = R.monomials_of_degree(2)
sage: mons
[x^2, x*y, x*z, y^2, y*z, z^2]
sage: sorted(mons)
[z^2, y*z, x*z, y^2, x*y, x^2]
sage:
```
CC: @videlec, @yyyyx4
### 📝 Checklist
<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
- [x] I have made sure that the title is self-explanatory and the
description concisely explains the PR.
- [x] I have linked an issue or discussion.
- [x] I have created tests covering the changes.
- [x] I have updated the documentation accordingly.
### ⌛ Dependencies
<!-- List all open pull requests that this PR logically depends on -->
<!--
- #xyz: short description why this is a dependency
- #abc: ...
-->
URL: https://github.com/sagemath/sage/pull/35043
Reported by: David Ayotte
Reviewer(s):