Debian Codegraph @

test/cases/dsl-sorts/sortaf-func-lit-var/mlr

raw
1 # Sort descending numeric on the index field
2 begin {
3 @records = []; # Define as an array, else auto-create will make a map
4 }
5 @records[NR] = $*; # Accumulate
6 end {
7 cmp = func (a, b) {
8 return b.index <=> a.index;
9 };
10 @records = sort(@records, cmp);
11 for (record in @records) {
12 emit record;
13 }
14 }