### Related

##### orderlessp-sort-sqrt

sort([sqrt(2), 0, -sq...

Calculate

##### orderlessp-sort

sort([12,23,3,14,124,...

Calculate

##### orderlessp-sort-sqrt

sort([sqrt(2), 0, -sq...

Calculate

##### orderlessp

orderlessp(4*x^5+2*x^...

Calculate

? orderlessp ;

Calculate

##### orderlessp-sort-sqrt

sort([sqrt(2), 0, -sq...

Calculate

##### orderlessp

orderlessp(4*x^5+2*x^...

Calculate

##### orderlessp-sort

sort([12,23,3,14,124,...

Calculate

##### orderlessp-sort

sort([123,123,124,11,...

Calculate

##### orderlessp-sort-sqrt

sort([sqrt(2), 0, -sq...

Calculate

### orderlessp

Run Example
```(%i1)? orderlessp ;

-- Function: orderlessp (<expr_1>, <expr_2>)
`ordergreatp' returns `true' if <expr_1> succeeds <expr_2> in the
canonical ordering of Maxima expressions, and `false' otherwise.

`orderlessp' returns `true' if <expr_1> precedes <expr_2> in the
canonical ordering of Maxima expressions, and `false' otherwise.

All Maxima atoms and expressions are comparable under
`ordergreatp' and `orderlessp', although there are isolated
examples of expressions for which these predicates are not
transitive; that is a bug.

The canonical ordering of atoms (symbols, literal numbers, and
strings) is the following.

(integers and floats) precede (bigfloats) precede (declared
constants) precede (strings) precede (declared scalars) precede
(first argument to `orderless') precedes ...  precedes (last
argument to `orderless') precedes (other symbols) precede (last
argument to `ordergreat') precedes ... precedes (first argument to
`ordergreat') precedes (declared main variables)

For non-atomic expressions, the canonical ordering is derived from
the ordering for atoms.  For the built-in `+' `*' and `^'
operators, the ordering is not easily summarized.  For other
built-in operators and all other functions and operators,
expressions are ordered by their arguments (beginning with the
first argument), then by the name of the operator or function.  In
the case of subscripted expressions, the subscripted symbol is
considered the operator and the subscript is considered an
argument.

The canonical ordering of expressions is modified by the functions
`ordergreat' and `orderless', and the `mainvar', `constant', and
`scalar' declarations.

Examples:

Ordering ordinary symbols and constants.  Note that `%pi' is not
ordered according to its numerical value.

(%i1) stringdisp : true;
(%o1)                         true
(%i2) sort ([%pi, 3b0, 3.0, x, X, "foo", 3, a, 4, "bar", 4.0, 4b0]);
(%o2) [3, 3.0, 4, 4.0, 3.0b0, 4.0b0, %pi, "bar", "foo", a, x, X]

Effect of `ordergreat' and `orderless' functions.

(%i1) sort ([M, H, K, T, E, W, G, A, P, J, S]);
(%o1)           [A, E, G, H, J, K, M, P, S, T, W]
(%i2) ordergreat (S, J);
(%o2)                         done
(%i3) orderless (M, H);
(%o3)                         done
(%i4) sort ([M, H, K, T, E, W, G, A, P, J, S]);
(%o4)           [M, H, A, E, G, K, P, T, W, J, S]

Effect of `mainvar', `constant', and `scalar' declarations.

(%i1) sort ([aa, foo, bar, bb, baz, quux, cc, dd, A1, B1, C1]);
(%o1)   [aa, bar, baz, bb, cc, dd, foo, quux, A1, B1, C1]
(%i2) declare (aa, mainvar);
(%o2)                         done
(%i3) declare ([baz, quux], constant);
(%o3)                         done
(%i4) declare ([A1, B1], scalar);
(%o4)                         done
(%i5) sort ([aa, foo, bar, bb, baz, quux, cc, dd, A1, B1, C1]);
(%o5)   [baz, quux, A1, B1, bar, bb, cc, dd, foo, C1, aa]

Ordering non-atomic expressions.

(%i1) sort ([1, 2, n, f(1), f(2), f(2, 1), g(1), g(1, 2), g(n), f(n, 1)]);
(%o1) [1, 2, f(1), g(1), g(1, 2), f(2), f(2, 1), n, g(n),
f(n, 1)]
(%i2) sort ([foo(1), X[1], X[k], foo(k), 1, k]);
(%o2)            [1, foo(1), X , k, foo(k), X ]
1              k

(%o1)                                true
(%i2) ```
Run Example
```sort ([11, -17, 29b0, 7.55, 3, -5/2, b + a, 9 * c,                19 - 3 * x]);
5
(%o1)        [- 17, - -, 3, 7.55, 11, 2.9b1, b + a, 9 c, 19 - 3 x]
2
(%i2)  sort ([11, -17, 29b0, 7.55, 3, -5/2, b + a, 9*c, 19 - 3*x],                ordergreatp);
5
(%o2)        [19 - 3 x, 9 c, b + a, 2.9b1, 11, 7.55, 3, - -, - 17]
2
(%i3)  sort ([%pi, 3, 4, %e, %gamma]);
(%o3)                       [3, 4, %e, %gamma, %pi]
(%i4)  sort ([%pi, 3, 4, %e, %gamma], "<
");
(%o4)                       [%gamma, %e, 3, %pi, 4]
(%i5)  my_list: [[aa,hh,uu], [ee,cc], [zz,xx,mm,cc], [%pi,%e]];
(%o5)        [[aa, hh, uu], [ee, cc], [zz, xx, mm, cc], [%pi, %e]]
(%i6)  sort (my_list);
(%o6)        [[%pi, %e], [aa, hh, uu], [ee, cc], [zz, xx, mm, cc]]
(%i7)  sort (my_list, lambda ([a, b], orderlessp (reverse (a),                reverse (b))));
(%o7)        [[%pi, %e], [ee, cc], [zz, xx, mm, cc], [aa, hh, uu]]
(%i8)  sort([%i,1+%i,2*x,minf,inf,%e,sin(1),0,1,2,3,1.0,1.0b0],                ordermagnitudep);
(%o8)  [minf, 0, sin(1), 1, 1.0, 1.0b0, 2, %e, 3, inf, %i, %i + 1, 2 x]
(%i9) ```
Run Example
```sort([123,123,124,11,325132,512,5125,232,525],orderlessp);
(%o1)          [11, 123, 123, 124, 232, 512, 525, 5125, 325132]
(%i2) ```

### Related Help

Help for Orderlessp