# [`⍒`](https://bpl.fast.ai//glyphs/del-stile.html) — Grade down / Grade down by

Function. Keys: `Alt-Backslash g`. Hanzi: `降`. Ranks: [`∞`](https://bpl.fast.ai//glyphs/infinity.html) monadic, `∞ ∞` dyadic

`⍒Y` gives positions that sort major cells descending. Stable, with the same [ordering](delta-stile.md) as Grade up.

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

`C⍒Y` orders characters by their position in `C`, with characters absent from `C` first.

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

See [`>`](greater-than.md) to sort.

## Fast combinations

BPL computes each of these combinations with a dedicated algorithm. [Trains](../evaluation.md#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 |

```bpl
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` raises a `DOMAIN` error.

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