# @salmonui/data-grid/engine/sort API reference

> 20 exported symbols of @salmonui/data-grid/engine/sort: 7 functions, 3 interfaces and 10 types.

Canonical: https://salmonui.dev/docs/reference/data-grid/engine-sort

```ts
import { … } from '@salmonui/data-grid/engine/sort';
```

## Functions

### resolveLeaf

Kind: function

Page: https://salmonui.dev/docs/reference/data-grid/engine-sort/resolveLeaf

```ts
function resolveLeaf<Row>(columns: ColumnSnapshot<Row>, key: string): CompiledColumn<Row> | undefined;
```

Resolves a column key (columnId, then field) to a leaf column.

### rowComparator

Kind: function

Page: https://salmonui.dev/docs/reference/data-grid/engine-sort/rowComparator

```ts
function rowComparator<Row>(rows: readonly Row[], keys: readonly SortKey<Row>[], locale: string): (x: number, y: number) => number;
```

Comparator equal to the order `sortRowOrder` produces for an ascending
input: sort keys, then source index. Reads codes and per-code values (and
per-code ranks where they exist) without repairing ranks, so an incremental
update never pays for rank maintenance: numeric keys compare directly (NaN
first, like rank 0); strings compare by rank when both codes are ranked and
by the locale collator otherwise (ranks are collator-consistent).

### updateSortedOrder

Kind: function

Page: https://salmonui.dev/docs/reference/data-grid/engine-sort/updateSortedOrder

```ts
function updateSortedOrder<Row>(input: RowModelSnapshot<Row>, previousOutput: Int32Array, delta: RowDelta, keys: readonly SortKey<Row>[], locale: string): Int32Array | null;
```

Incremental sort: the previous sorted order minus changed rows, with the
changed rows of the new input inserted by binary search. Requires an
ascending input (ties are broken by source index, which is what the stable
full sort does for such an input). Null when a full sort is preferable.

## Interfaces

### SortKey

Kind: interface

Page: https://salmonui.dev/docs/reference/data-grid/engine-sort/SortKey

```ts
interface SortKey<Row> {
    readonly column: CompiledColumn<Row>;
    readonly desc: boolean;
}
```

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `column` | `readonly column: CompiledColumn<Row>;` |  |  |
| `desc` | `readonly desc: boolean;` |  |  |

## Re-exported entry points

- [@salmonui/data-grid/engine](https://salmonui.dev/docs/reference/data-grid/engine.md): 16 symbols: 4 functions, 2 interfaces and 10 types
  `SortClearCommand`, `SortColumnCommand`, `SortCommand`, `SortDescriptorInput`, `SortMode`, `SortModule`, `SortOptions`, `SortRemoveCommand`, `SortSetCommand`, `SortSetOptionsCommand`, `SortState`, `SortToggleCommand`, `createSortModule`, `effectiveSortKeys`, `getSortInfo`, `sortRowOrder`
