Question: Defining order on a set of variables.

Hi everyone

I am stuck in my code. I have a multivariate polynomial and I am trying to define an order on the variables such that I can write my polynomials in a desired normal form. I tried with the Groebner package but that's quite different from what I want.

I want to define the order on the variables as u[i]=v[i] and u[i]<u[i+1].

Lets say my polynomial is f then,

input f= u[1]^2+u[2]+v[3]

output f = v[3]+u[2]+u[1]^2.

If there is a clash between u and v then, either of them can come first, for example,

input f= u[1]^2+u[2]+v[3]+u[3]^2

 output f=v[3]+u[3]^2+u[2]+u[1]^2 or f=u[3]^2+v[3]+u[2]+u[1]^2

I hope my question is clear. Thank you for helping me out. Your time is much appreciated :)
EDIT 1: Comment towards the end of the answer is a solution for this question.

Please Wait...