Documentation contents

atlas Library · Script File

sort.at

Source
atlas-scripts/sort.at (215 lines)
Definitions
56
Loads
Loaded by
combinatorics.at galois.at W_reps.at all_finite_order.at weyltosemisimple.at bruhat.at Weylgroup.at K.at W_orbit.at Levi_subgroups.at diagram.at lietypes.at poset.at cyclotomic.at class_tables.at character_table_E6.at e8_gap.at springer_table_F.at W_reps_type_BC.at W_order.at

Definitions in source order

is_sorted

L6any_type Tis_sorted ((T,T->bool)leq) = ([T] a)bool
a user function to verify that sorting has worked

merge

L11any_type Tmerge ((T,T->bool)leq) = ([T] a, [T] b) [T]
merge weakly increasing lists

also in this file at line 62; also defined in nilpotent_posets.at

sort

L25any_type Tsort ((T,T->bool)leq) = ([T]->[T])
merge sort

also in this file at line 59, line 60, line 61; also defined in sommers.at, nilpotent_posets.at, hodge_functions.at

merge_u

L33any_type Tmerge_u ((T,T->bool)leq) = ([T] a, [T] b) [T]
merge unique weakly increasing lists

also in this file at line 69, line 70, line 71

sort_u

L50any_type Tsort_u ((T,T->bool)leq) = ([T]->[T])
sort, keeping unique copy of duplicates

also in this file at line 66, line 67, line 68; also defined in K_types.at, nilpotent_posets.at

sort 3 overloads

L59sort = sort(<=@(int,int))
L60sort = sort(<=@(rat,rat))
L61sort = sort(<=@(string,string))

also in this file at line 25; also defined in sommers.at, nilpotent_posets.at, hodge_functions.at

merge

L62merge = merge(<=@(int,int))
used separately in combinatorics.at

also in this file at line 11; also defined in nilpotent_posets.at

reverse_sort 3 overloads

L63reverse_sort = sort(>=@(int,int))
L64reverse_sort = sort(>=@(rat,rat))
L65reverse_sort = sort(>=@(string,string))

sort_u 3 overloads

L66sort_u = sort_u(<=@(int,int))
L67sort_u = sort_u(<=@(rat,rat))
L68sort_u = sort_u(<=@(string,string))

also in this file at line 50; also defined in K_types.at, nilpotent_posets.at

merge_u 3 overloads

L69merge_u = merge_u(<=@(int,int))
L70merge_u = merge_u(<=@(rat,rat))
L71merge_u = merge_u(<=@(string,string))

also in this file at line 33

the following helps stable-sorting of anything according to a statistic
L73

ranking

L84any_type S, Tranking ((T,T->bool)leq) = ([T] a) [int]
Compute list |R| such that |R[i]| is index of element ranked |i| for |leq|.
For $i<j$ one will have |leq(a[R[i]],a[R[j]])|, and in case of equality
(the comparison also holds in the opposite order) one also has |R[i]<R[j]|
(stability). This is the inverse of the permutation that stable-sorts the list
|a| into into order for |leq|, the latter being called the standardisation of
|a|. Therefore this function used to be called |inv_standardisation|.

also in this file at line 138, line 139, line 140, line 192, line 209

sort_by

L87any_type S, Tsort_by ((T->S)f,(S,S->bool)leq) = ([T]->[T])

also in this file at line 106, line 107

merge_by

L90any_type S, Tmerge_by ((T->S)f,(S,S->bool)leq) = ([T],[T]->[T])
don't bother to improve this

sort_u_by

L92any_type S, Tsort_u_by ((T->S)f,(S,S->bool)leq) = ([T]->[T])

merge_u_by

L103any_type S, Tmerge_u_by ((T->S)f,(S,S->bool)leq) = ([T],[T]->[T])

sort_by 2 overloads

L106any_type S, Tsort_by ((T->int) f) = ([T]->[T])
when sorting by integer or rational value, default to increasing sort
L107any_type S, Tsort_by ((T->rat) f) = ([T]->[T])

also in this file at line 87

lookup_in

L109any_type S, Tlookup_in ([S]a,(S->T)f,(T,T->bool) leq) = (T->Maybe<S>)

partition_by

L113any_type S, Tpartition_by ((T->S)f,(S,S->bool)leq) = ([T] a) [[T]]
group together elements with the same value under |f|, ordered by that value

representatives_by

L121any_type S, Trepresentatives_by ((T->S)f,(S,S->bool)leq) = ([T] a) [T]
similar, but keep only one (the first) element for each value of |f|

lexicographic

L128any_type S, Tlexicographic ((T,T->bool)leq) = ([T] a,[T] b) bool
let length difference decide if one is prefix ot the other
L134

ranking 3 overloads

L138ranking = ranking(<=@(int,int))
L139ranking = ranking(<=@(rat,rat))
L140ranking = ranking(<=@(string,string))

also in this file at line 84, line 192, line 209

Here are example calls of the model functions above. They can be defined here
because reducibility_points and height are built-in functions (those defined
in basic.at could also be used). If however you need to sort on a custom
attribute defined elsewhere, DON'T do so here (and don't include modules to
make that possible); rather call sort_by in the script where that custom
attribute is defined.

For instance LKT.at defines the |attribute LKT_dimensions|, and then defines
sort_by_dimension in a call of sort_by, whose argument uses that attribute.
L142

sort_by_reducibility_points

L154sort_by_reducibility_points = ([(Param,bool)]->[(Param,bool)])
sort list of pairs [(Param,bool)] by #reducibility_points of Param

sort_by_reducibility

L158sort_by_reducibility = ([Param]->[Param])
sort list [Param] by #reducibility_points of Param

sort_by_height 4 overloads

L162sort_by_height = ([KType] -> [KType])
Sort list of parameters by height
L163sort_by_height = ([Param] -> [Param])
L166sort_by_height = ([(Split,KType)] -> [(Split,KType)])
Same with a Split attached, which is ignored for sorting
L168sort_by_height = ([(Split,Param)] -> [(Split,Param)])

also defined in K_norm.at

lex_leq

L172lex_leq (vec v,vec w) = bool
comparing vectors lexicographically
assert(@:#v=#w);

rlex_leq

L179rlex_leq (vec v,vec w) = bool
compariung fixed size vectors lexicographically (restricted lex ordering)
assert(@:#v=#w);

slex_leq

L183slex_leq (vec v,vec w) = bool
short lex ordering
for types [T], including [int], one can also use |lexicographic(leq@(T,T))|
L189

ranking

L192ranking = ranking(lex_leq@(vec,vec))

also in this file at line 84, line 138, line 139, line 140, line 209

sort_lex

L193sort_lex = sort(lex_leq@(vec,vec))

also in this file at line 210

sort_u_lex

L194sort_u_lex = sort_u(lex_leq@(vec,vec))

also in this file at line 211

sort_rlex

L195sort_rlex = sort(rlex_leq@(vec,vec))

also in this file at line 212

sort_u_rlex

L196sort_u_rlex = sort_u(rlex_leq@(vec,vec))

also in this file at line 213

sort_slex

L197sort_slex = sort(slex_leq@(vec,vec))

also in this file at line 214

sort_u_slex

L198sort_u_slex = sort_u(slex_leq@(vec,vec))

also in this file at line 215

(lex_leq, rlex_leq, slex_leq)

L201(lex_leq,rlex_leq,slex_leq) = …
comparing rational vectors

ranking

L209ranking = ranking(lex_leq@(ratvec,ratvec))

also in this file at line 84, line 138, line 139, line 140, line 192

sort_lex

L210sort_lex = sort(lex_leq@(ratvec,ratvec))

also in this file at line 193

sort_u_lex

L211sort_u_lex = sort_u(lex_leq@(ratvec,ratvec))

also in this file at line 194

sort_rlex

L212sort_rlex = sort(rlex_leq@(ratvec,ratvec))

also in this file at line 195

sort_u_rlex

L213sort_u_rlex = sort_u(rlex_leq@(ratvec,ratvec))

also in this file at line 196

sort_slex

L214sort_slex = sort(slex_leq@(ratvec,ratvec))

also in this file at line 197

sort_u_slex

L215sort_u_slex = sort_u(slex_leq@(ratvec,ratvec))

also in this file at line 198

Generated from atlas-scripts at commit 648506c (2026-10-13).