Skip to main content

CSV sorting guide

How to sort a CSV by text or numeric columns

Open Sort rows

Sort by State ascending, Amount descending, or up to three prioritized keys. Rows equal on every selected key retain their original order.

Published:

Updated:

Related tool: Sort rows

Example: highest sales within each state

Sort State as ascending text and Amount USD as descending numbers, with blanks last.

  • Key 1: State, text, ascending
  • Key 2: Amount USD, number, descending
  • Blank values: last

Unsorted sales

States and amounts are mixed in the input.

state_sales.csv
Invoice,State,Amount USD
V001,Texas,840.00
V002,California,1280.00
V003,Texas,2150.00
V004,California,990.00

Sort by multiple columns

Choose Number for numeric fields so 100 sorts after 20.

  1. Open Sort rows and choose the CSV.
  2. Configure column, type, direction, and blank placement for key 1.
  3. Add and reorder up to two more keys when needed.
  4. Confirm case sensitivity and run the sort.
  5. Verify counts and check the first and last rows, then download.
Sort rows

State ascending, amount descending

California precedes Texas, and the larger amount comes first within each state.

state_sales_sorted.csv
Invoice,State,Amount USD
V002,California,1280.00
V004,California,990.00
V003,Texas,2150.00
V001,Texas,840.00

Common sorting mistakes

Text and number modes produce intentionally different orderings.

  • Sorting money as text
  • Selecting Number for values with commas or currency signs
  • Sorting mixed date formats as plain text
  • Assuming ascending or descending decides blank placement

Where this sort fits

It is useful for presentation order and as a preparation step before deduplication.

  • Good fit: up to three text or numeric keys
  • Good fit: preserve the order of ties
  • Date-aware sorting and language-specific alphabetical order are unsupported
  • Use Group and summarize to create summaries