---
title: "Multi-Column Sorting"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Multi-Column Sorting}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```

`dtsmartr` supports complex multi-column sorting natively from the grid headers.

## 1. Single Column Sort
Clicking the sorting icon (⇅) on any column opens a dedicated dropdown menu:
- **↑ Sort ascending (Primary)**: Sets this column as the primary ascending sort variable, replacing previous selections.
- **↓ Sort descending (Primary)**: Sets this column as the primary descending sort variable, replacing previous selections.

## 2. Multi-Column Sort
To sort by multiple columns sequentially (e.g. sort by `CYL` first, then sort by `MPG` inside each cylinder class):
- Click the sorting icon (⇅) on the first column and select **Sort ascending (Primary)**.
- Click the sorting icon (⇅) on the second column and select **➕ Add to sort (Ascending)** or **➕ Add to sort (Descending)**.
- The UI will display sequence badges (e.g., `(1)`, `(2)`) next to the sorting direction indicators to help you track your sorting priority order.

## 3. Clearing Column Sorts
- To remove a single column from the multi-column sort list, open its sorting dropdown and select **❌ Remove from sort**.
- To clear all sorting configurations at once, click the **Clear sort** link in the toolbar at the top of the grid.
