# SortState

> _Since v0.2.7_

Sort state passed to custom sort handlers.
Represents the current sorting configuration for a column.

#### Example

```typescript
// In a custom sort handler
const sortHandler: SortHandler = (rows, sortState, columns) => {
  const { field, direction } = sortState;
  console.log(`Sorting by ${field} ${direction === 1 ? 'ASC' : 'DESC'}`);

  return [...rows].sort((a, b) => {
    const aVal = a[field];
    const bVal = b[field];
    return (aVal < bVal ? -1 : aVal > bVal ? 1 : 0) * direction;
  });
};
```

## Properties

| Property | Type | Description |
| -------- | ---- | ----------- |
| `field` | <code>string</code> | Field to sort by |
| `direction` | <code>-1 &#124; 1</code> | Sort direction: 1 = ascending, -1 = descending |

## See Also

- [`SortHandler`](/grid/api/core/types/sorthandler.md) for custom sort handler signature
- [`SortChangeDetail`](/grid/api/core/interfaces/sortchangedetail.md) for sort change events
