# SORTBY Function

> Sort a range or array by the values of other arrays with SORTBY in TX Sheet Control: sort keys, order, ties, the required sort order and #VALUE!.

- **Product:** TX Sheet Control
- **Section:** Documentation
- **Kind:** Function
- **Path:** TX Sheet Control > API Reference > Formula Functions > SORTBY Function
- **248 words**
- **Web URL:** https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/sortby/
- **LLMs URL:** https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/sortby/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/sortby/llms-full.txt

---

Return the values of an array sorted by the values of another array. `by_array1` holds the sort keys and must have as many rows (or columns) as `array`, and `sort_order1` is 1 for ascending or -1 for descending; further pairs of `by_array` and `sort_order` break ties. The sorted array spills into the neighboring cells. In TX Sheet Control, `sort_order1` is required: without it, or with a key array of another size, SORTBY returns `#VALUE!`.

### Syntax

```text
SORTBY(array, by_array1, sort_order1)
```

Category: Lookup. Minimum arguments: 3. Maximum arguments: 255.

Available for supported offline calculation.

### Examples

```text
=SORTBY({"a";"b";"c"},{3;1;2},1)
```

The formula spills b, c and a: the keys 1, 2 and 3 put the values in that order.

Cell and range examples require appropriate input values in the referenced cells. Handle invalid arguments, formula errors and array and spill constraints.

### See Also

- [Formulas](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/formulas/llms-full.txt)
- [Custom Functions and Formula Data](https://docs.textcontrol.com/tx-sheet-control/spreadsheets/custom-functions/llms-full.txt)

---

## Nearby

- **Previous:** [SORT Function](https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/sort/llms-full.txt)
- **Next:** [SQRT Function](https://docs.textcontrol.com/tx-sheet-control/reference/formula-functions/sqrt/llms-full.txt)
