grade

From The K Language Wiki
(Redirected from Grade up)
Grade
<x
>x

grade returns the domain of a collection (list, table, or dictionary) sorted by its range. It has two versions: up (<x) and down (>x), a.k.a. asc and desc by analogy with SQL.

Grade uses a stable sorting algorithm - equivalent items are sorted in their original order.

Sorting (as in sorting the range by itself) can be implemented through the idiom x@<x or x@>x. K7 and k9 support an additional dedicated sort-ascending primitive: ^x.

 >34 -1 0 67 32767
4 3 0 2 1

 {x(<x)}("xyz";"a";"k";"j";"apl";"bqn")
("apl"
 "bqn"
 "xyz"
 "a"
 "j"
 "k")