The first function sorts the elements of the list in V with respect
to the default comparisons related to their types; it overwrites V.
The second function, 'Sorted', returns the list of the sorted elements
of L without affecting L, itself. For more on the default
comparisions, see 'Relational Operators' in the chapter on operators.
For more complicated sorting, see 'SortBy, SortedBy'.
|
L := [3,2,1];
Sort(L);
L;
[1, 2, 3]
-------------------------------
Use R ::= Q[x,y,z];
L := [x,y,z];
Sort(L);
L;
[z, y, x]
-------------------------------
Sorted([y,x,z,x^2]);
[z, y, x, x^2]
-------------------------------
Sorted([3,1,1,2]);
[1, 1, 2, 3]
-------------------------------
Sorted(["b","c","a"]);
["a", "b", "c"]
-------------------------------
Sorted([Ideal(x,y),Ideal(x)]); -- ideals are ordered by containment
[Ideal(x), Ideal(x, y)]
-------------------------------
|