|
D.2.2.14 sort
Procedure from library general.lib (see general_lib).
- Usage:
sort(id[v,o,n]); id = ideal/module/intvec/list(of intvec’s or int’s)
sort may be called with 1, 2 or 3 arguments in the following way:
sort(id[v,n]); v=intvec of positive integers, n=integer,
sort(id[o,n]); o=string (any allowed ordstr of a ring), n=integer
- Return:
a list l of two elements:
- Note:
If v is given id may be any simply indexed object (e.g. any list or
string); if v[i]<0 and i<=size(id) v[i] is set internally to i;
entries of v must be pairwise distinct to get a permutation if id.
Zero generators of ideal/module are deleted
Example:
LIB "general.lib";
ring r0 = 0,(x,y,z,t),lp;
ideal i = x3,z3,xyz;
sort(i); //sorts using lex ordering, smaller polys come first
→ [1]:
→ _[1]=z3
→ _[2]=xyz
→ _[3]=x3
→ [2]:
→ 2,3,1
sort(i,3..1);
→ [1]:
→ _[1]=xyz
→ _[2]=z3
→ _[3]=x3
→ [2]:
→ 3,2,1
sort(i,"ls")[1]; //sort w.r.t. negative lex ordering
→ _[1]=x3
→ _[2]=xyz
→ _[3]=z3
intvec v =1,10..5,2..4;v;
→ 1,10,9,8,7,6,5,2,3,4
sort(v)[1]; // sort v lexicographically
→ 1,2,3,4,5,6,7,8,9,10
sort(v,"Dp",1)[1]; // sort v w.r.t (total sum, reverse lex)
→ 10,9,8,7,6,5,4,3,2,1
|