## Sorting Columns in Trusty CSV

To sort data by columns in Trusty CSV, position the cursor in the column of interest and select either **Columns › Sort Ascending** or **Columns › Sort Descending**. This action rearranges the rows based on the selected column while keeping the header row at the top; a row with line breaks in a value will move as a whole.

### Sorting Multiple Columns

To sort by multiple columns or to specify how values are compared, use the **Columns › Sort by Several Columns…** option found in the column’s menu. This also appears when clicking the three dots next to the column number in the column bar, starting with the current column.

### Example of a Data Set

| product         | category | price |
|------------------|----------|-------|
| Espresso         | coffee   | 2.20  |
| Matcha latte     | tea      | 4.20  |
| Flat white       | coffee   | 3.40  |
| Chai             | tea      | 3.60  |
| Cold brew        | coffee   | 10.90 |
| Cortado          | coffee   | 3.10  |
| Croissant        | bakery   | 2.60  |
| Earl grey        | tea      | 2.90  |
| Cappuccino       | coffee   | 3.30  |
| Banana bread     | bakery   | 3.20  |
| Mocha            | coffee   | 3.90  |
| Green tea       | tea      | 2.70  |
| Cinnamon roll    | bakery   | 3.50  |
| Americano        | coffee   | 2.60  |
| Rooibos          | tea      | 2.80  |
| Brownie          | bakery   | 2.95  |
| Macchiato        | coffee   | 2.90  |
| Iced tea         | tea      | 3.10  |
| Muffin           | bakery   | 2.75  |
| Latte            | coffee   | 3.50  |

### Numeric and Date Sorting

Trusty CSV sorts numbers by their value; for instance, `9.50` sorts before `10.00`, taking into account the column’s decimal separator. A column filled with dates is sorted by day and time, regardless of formatting, with `31/12/2025`, `2026-01-05`, and `5 Jan 2026 9:30` appearing in chronological order.

### Comparing Text Values

When sorting text, the software uses a conventional word order—not distinguishing between capital and lowercase letters. For example, `Item 2` would be before `Item 10`. Any rows that contain empty cells or values inconsistent with the column type will be moved to the end.

### Sorting Behavior

When using **Sort by Several Columns...**, a window appears that allows the user to select the sort order for up to five columns. The first listed column is the primary sort key, followed by the secondary, tertiary, and so on, allowing for elaborate sorting structures.

### Summary of Types of Sort
- **Automatic**: Default sorting based on data type.
- **As Text**: Sorts purely by the written values.
- **By Length**: Sorts based on the character count of each value.

Empty cells and `null` values always appear at the end, maintaining consistency in sorting.
