CoCoA:Sorted

From ApCoCoAWiki
Revision as of 10:02, 24 October 2007 by XMLBot (talk | contribs) (pushing XML rev. 1.46, again)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Sorted

sort a list

Description

This function returns the list of the sorted elements of L without

affecting L, itself.

For more on the default comparisons, see Relational Operators

in the chapter on operators.

For more complicated sorting, see <ttref>SortBy</ttref>, <ttref>SortedBy</ttref>.

Example

  L := [3,2,1];
  Sorted(L);
[1, 2, 3]
-------------------------------
  Use R ::= Q[x,y,z];
  L := [x,y,z];
  Sorted(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([<quotes>b</quotes>,<quotes>c</quotes>,<quotes>a</quotes>]);
[<quotes>a</quotes>, <quotes>b</quotes>, <quotes>c</quotes>]
-------------------------------
  Sorted([Ideal(x,y),Ideal(x)]); -- ideals are ordered by containment
[Ideal(x), Ideal(x, y)]
-------------------------------

Syntax

Sorted(L:LIST):LIST

where V is a variable containing a list.

Relational Operators

SortBy

SortedBy

Sort

   <type>list</type>