Ordering multivariate polynomials (AbstractAlgebra)

The call ordering(R) = :degrevlex is not doing what you think it is. You are just defining a function ordering with one argument called R.

One has to supply the ordering when creating the polynomial ring:

julia> R, (X, Y) = PolynomialRing(QQ, ["X", "Y"], ordering = :deglex)
(Multivariate Polynomial Ring in X, Y over Rationals, AbstractAlgebra.Generic.MPoly{Rational{BigInt}}[X, Y])

julia> g = X^2*Y + 3X*Y^5 + 1
3*X*Y^5 + X^2*Y + 1

Edit: :lex is lexicographical ordering. :deglex is first by degree and then lexicographical. For :degrevlex I refer you to Wikipedia.