# [`<`](https://bpl.fast.ai//glyphs/less-than.html) — Sort up / Less

Function. Hanzi: `小`. Ranks: [`∞`](https://bpl.fast.ai//glyphs/infinity.html) monadic, `0 0` dyadic

`<Y` sorts the major cells of `Y` ascending, as `[⍋Y]⌷Y` does. Ties keep their order.

```bpl
<30 10 20           ⍝ 10 20 30
<"banana"           ⍝ "aaabnn"
<[3 1◇1 2◇2 0]  ⍝ [1 2◇2 0◇3 1]
```

`X<Y` tests X \< Y for reals, and for characters by code point. A number is less than any character, as [`⍋`](delta-stile.md) orders them. Pervasive; [tolerant](../evaluation.md#equality-and-ordering).

```bpl
1 2 3<2            ⍝ $t $f $f
"abc"<"abd"        ⍝ $f $f $t
3<'a'              ⍝ $t
```

See [`>`](greater-than.md) to sort down, and [`⍋`](delta-stile.md) for the indices that 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 `k` smallest items, or the `-k` largest, without ordering the rest |
| `↑<Y`, `i⌷<Y` or `i⊃<Y` | the same vectors | selects the item of rank `i`, such as a median, without ordering the rest |

```bpl
v←30 10 20 50 40 60 70 80 90 0
2↑< v                                ⍝ 0 10
5⌷< v                                ⍝ 50
(•explain "5⌷< v").fast.rule         ⍝ ["partial sort"]
```
