Skip to main content

⍒ — Grade down / Grade down by

Function. Keys: Alt-Backslash g. Hanzi: 降. Ranks: ∞ monadic, ∞ ∞ dyadic

⍒Y gives indices that sort major cells descending. Stable, with the same ordering as Grade up.

⍒30 10 20          ⍝ [0 2 1]ₓ
⍒2 1 2 1           ⍝ [0 2 1 3]ₓ

C⍒Y uses character collation C.

"cba"⍒"abc"        ⍝ [0 1 2]ₓ

See > to sort.

Fast combinations

BPL computes each of these combinations by an algorithm of its own, in any spelling. Trains says which spellings BPL recognises.

Combination Applies to Benefit
k↑⍒Y, k↑⍒ Y or (k↑)∘⍒ a vector of reals or characters without keys selects the first k positions of the descending grade, or the last -k, without ordering the rest
↑⍒Y, i⌷⍒Y or i⊃⍒Y the same vectors selects one position without ordering the rest
⍋⍒Y, ⍋⍒ Y or ⍋∘⍒ any Y without keys on its first axis gives each major cell’s rank in descending order by inverting the grade, without grading it again
v←30 10 20 50 40 60 70 80 90 0
2↑⍒ v                                ⍝ [8 7]ₓ
⍋⍒ v                                 ⍝ [6 8 7 4 5 3 2 1 0 9]ₓ
(•explain "2↑⍒ v").fast.rule         ⍝ ["partial grade"]

Inverse

⍒⁻P gives an array whose descending grade is the permutation P. Any other P is a DOMAIN error.

⍒⁻2 0 1   ⍝ [1 0 2]ₓ