fixed sorting of coefficients