Changing the order of variables: reorder

### 5.27.27 Changing the order of variables: reorder

The reorder command rewrites an expression, based on the priority of variables.

- reorder takes two arguments:
  - expr, an expression.
  - vars, a vector of variable names.
- reorder(expr,vars) expands expr according to the order of variables given in vars.

#### Example

Input:

reorder(x^2+2*x*a+a^2+z^2-x*z,[a,x,z])

Output:

a2+2 a x+x2−x z+z2

Warning.
The variables must be symbolic (if not, purge them (see Section 4.4.8) before calling reorder.