Sort
Filter & SortReorder all rows in the dataset by a selected column in ascending or descending order. Sorting is a non-destructive operation -- no data is added or removed, only the row order changes. Use it to organise data for inspection, find extreme values, or prepare a clean ordering before export.
When to Use
- You need data ordered by a specific variable before visual inspection or export (e.g., alphabetical by gene name, by p-value from smallest to largest, or by date).
- You want to rank observations by a numeric column to quickly identify the highest or lowest values (e.g., top-scoring subjects, lowest expression genes).
- You are preparing a dataset for presentation or publication and need a consistent, reproducible row ordering.
- You want to visually inspect whether data appears to have a trend or pattern when ordered by a particular variable.
Required Inputs
- Column -- the column to sort by. Any column in the dataset can be selected as the sort key.
- Direction -- ascending (A to Z for text, smallest to largest for numbers) or descending (Z to A, largest to smallest). Choose the direction that puts the most relevant values at the top.
What Changes
- Row order changes -- rows are rearranged according to the sort column and direction.
- No rows or columns are added or removed. The dataset size remains exactly the same.
- The operation is applied in place, replacing the previous row order. Use undo to restore the original ordering if needed.
- Ties (rows with equal values in the sort column) retain their relative order from before the sort (stable sort).
Common Pitfalls
- Numeric columns stored as text sort lexicographically rather than numerically ("9" sorts after "10" because "9" > "1" character by character). Convert the column to numeric type first to get correct numeric ordering.
- Empty or missing values typically sort to the end of the result regardless of sort direction. Be aware of this if your dataset contains gaps.
- This dialog applies one sort key at a time. Applying a new sort replaces the previous sort order entirely rather than adding a secondary sort key. If you need multi-column sorting, sort by the least important key first, then by the most important key.
Example: Before & After
Before
| Name | Score |
|---|---|
| Alice | 75 |
| Bob | 92 |
| Carol | 88 |
→
After
| Name | Score |
|---|---|
| Bob | 92 |
| Carol | 88 |
| Alice | 75 |
Sort by Score, descending. Bob (92) moves to the top, Alice (75) moves to the bottom.