grade up

From The K Language Wiki
Revision as of 08:48, 9 July 2021 by Razetime (talk | contribs) (add grade up page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Grade up
<x

The grade up primitive is used to get the indices of an array that would sort it in ascending order.

Since grading is not the same as sorting, a general idiom used to sort arrays is {x(<x)} or other equivalent.

For integer arrays:

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

Grading of string arrays largely depends upon the implementation.

For ngn/k(K6), groups by length and sorts each individual group:

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