tsvkit.org
TSV Toolkit
Sample data Say hi →

Sort TSV by Column

multi-key · numeric-aware · stable · runs in your browser

Paste a tab-separated file and sort it by any column — by name if it has a header, or by 1-indexed position if it doesn't. The header row is held in place rather than sorted into the data. Sorting is stable: rows that tie on every key keep their original relative order, so sorting by country then re-sorting by date gives you a predictable nested order rather than a shuffle.

sort
Drop a .tsv file here, or
ready

How to use

  1. Paste or drop your TSV. The first row is treated as a header unless you tick no header row.
  2. Name the sort column in the By field — either the header text (revenue) or its 1-indexed position (3).
  3. For a multi-key sort, comma-separate themcountry,city sorts by country first, then city inside each country.
  4. Pick an order type if auto guesses wrong. Auto compares numerically when both values parse as numbers and falls back to text otherwise.
  5. Copy or download the result. Nothing was uploaded to get here.

Auto, numeric, text, and date order

Auto is right most of the time: it compares two values numerically if both look numeric, otherwise as text. The case it gets wrong is a mixed column — 12, 7, n/a — where the non-numeric rows fall back to text comparison and land unpredictably relative to the numbers. Force numeric there and non-numeric values sort to the end as a block.

Text order is plain lexicographic on the raw string, which means 10 sorts before 9 and leading zeros are preserved — that's the mode you want for IDs, SKUs, and zip codes that must not be coerced. Date order parses each value with the browser's date parser; ISO dates (2026-07-19) always work, and ambiguous formats like 07/19/26 are interpreted US-style. If your dates aren't ISO, run them through reformat dates first and then sort as text — ISO strings sort correctly as text, which is the whole point of the format.

What it does to your data

Nothing except reorder whole rows. Cells are never rewritten, columns are never dropped, and trailing blank lines are discarded. Rows shorter than the header are compared as if the missing cells were empty strings, so a ragged file will sort without error — but you probably want to know it's ragged, so run the validator or fix ragged rows first.

FAQ

How do I sort by a column when the file has no header?

Tick no header row and use 1-indexed positions in the By field — 2 is the second column. With that box ticked, every row including the first is treated as data and sorted.

Can I sort one column ascending and another descending?

Not in a single pass — the direction applies to all keys. Because the sort is stable you can do it in two passes instead: sort by the descending key first, then sort by the ascending key. The second sort preserves the first one's order within ties.

Why did my leading zeros survive?

Because values are never coerced — sorting compares them, it doesn't rewrite them. 00742 stays 00742 in the output regardless of which order mode you pick. Only the TSV → JSON converter will coerce types, and only when you explicitly ask it to.

Is there a size limit?

Only your browser's memory. Live re-sorting is skipped above roughly 5 MB of pasted text to keep typing responsive; drop the file instead and it will process once. Files in the tens of megabytes generally work, but a 500 MB export is a job for sort -t$'\t' -k2 on the command line.

What's the shell equivalent?

(head -1 file.tsv; tail -n +2 file.tsv | sort -t$'\t' -k3,3n) > sorted.tsv — the subshell is what keeps the header on top, and -k3,3n is a numeric sort on column 3. This page exists mostly so you don't have to remember that.

Privacy

100% client-side. No upload. See the privacy policy.