Grade down: Difference between revisions

From The K Language Wiki
Content added Content deleted
(grade down)
 
(add stable sort)
Line 3: Line 3:


Since grading is not the same as sorting, a general idiom used to sort arrays is <code>{x(>x)}</code> or other equivalent.
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 descending grade may not always be the inverse of an ascending grade.


For numeric arrays:
For numeric arrays:

Revision as of 05:39, 11 July 2021

Grade down
>x

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

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

Grade primitives generally use a stable sort, which means that an descending grade may not always be the inverse of an ascending grade.

For numeric arrays:

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

Grading of string arrays largely depends upon the implementation, as shown in grade up.