p = (x + (x^2) - 1)*((y^2) - x + 3)*((y^2) - (x^3))

Collect[p, x]

Collect[p, y]

s = Collect[Expand[p], y]

InputForm[s]