Grade up: Difference between revisions

From The K Language Wiki
Content added Content deleted
mNo edit summary
(Redirected page to Grade)
Tag: New redirect
Line 1: Line 1:
#redirect [[grade]]
{{primitive|<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 <code>{x(<x)}</code> or other equivalent.

Grade primitives generally use a [https://en.wikipedia.org/wiki/Category:Stable_sorts stable sort], which means that an ascending grade may not always be the inverse of a descending grade.

For numeric arrays:
<pre>
<34 -1 0 67 32767
1 2 0 3 4</pre>

Grading of string arrays largely depends upon the implementation.

For ngn/k(K6), groups by type and sorts each individual group:
<pre>
{x(<x)}("xyz";"a";"k";"j";"apl";"bqn")
("apl"
"bqn"
"xyz"
"a"
"j"
"k")
</pre>

Revision as of 17:01, 14 July 2021

Redirect to: