# Singular          #### D.8.2.12 sortvars

Procedure from library `presolve.lib` (see presolve_lib).

Usage:
sortvars(id[,n1,p1,n2,p2,...]);
id=poly/ideal/vector/module,
p1,p2,...= polynomials (product of vars),
n1,n2,...= integers
(default: p1=product of all vars, n1=0)
the last pi (containing the remaining vars) may be omitted

Compute:
sort variables with respect to their complexity in id

Return:
list of two elements, an ideal and a list:
 ``` : ideal, variables of basering sorted w.r.t their complexity in id ni controls the ordering in i-th block (= vars occuring in pi): ni=0 (resp. ni!=0) means that less (resp. more) complex vars come first : a list with 4 entries for each pi: _: ideal ai : vars of pi in correct order, _: intvec vi: permutation vector describing the ordering in ai, _: intmat Mi: valuation matrix of ai, the columns of Mi being the valuation vectors of the vars in ai _: intvec wi: size of 1-st, 2-nd,... block of identical columns of Mi (vars with same valuation) ```

Note:
We define a variable x to be more complex than y (with respect to id) if val(x) > val(y) lexicographically, where val(x) denotes the valuation vector of x:
consider id as list of polynomials in x with coefficients in the remaining variables. Then:
val(x) = (maximal occuring power of x, # of all monomials in leading coefficient, # of all monomials in coefficient of next smaller power of x,...).

Example:
 ```LIB "presolve.lib"; ring s=0,(x,y,z,w),dp; ideal i = x3+y2+yw2,xz+z2,xyz-w2; sortvars(i,0,xy,1,zw); ==> : ==> _=x ==> _=y ==> _=z ==> _=w ==> : ==> : ==> _=y ==> _=x ==> : ==> 2,1 ==> : ==> 2,3, ==> 1,1, ==> 2,0, ==> 0,2 ==> : ==> 1,1 ==> : ==> _=w ==> _=z ==> : ==> 2,1 ==> : ==> 2,2, ==> 2,1, ==> 0,2 ==> : ==> 1,1 ```

### Misc 