Open or paste a CSV file, choose the column to Sort by, how to Compare as and the Order, and the sorted rows appear immediately. Add Then by columns to break ties, up to 20 in total. Rows with equal values keep their original order, empty or unreadable values go to the end (or the start), and no cell text is changed. The file is sorted in your browser, not uploaded.
How to sort a CSV file
- Open a
.csv,.tsvor.txtfile, drop it on the tool, or paste rows. The delimiter and a UTF-8 or UTF-16 byte-order mark are detected; choose another delimiter or a legacy encoding under Import settings. - The first sort column is preset to the file’s first column, ascending, as Text (file2 before file10). Change Sort by, Compare as and Order as needed.
- Select Add another column to add a Then by key; it decides the order only among rows that tie on the keys above it. Use the arrows to change the priority.
- Choose where Empty or non-matching values go: At the end or At the start.
- Select Download CSV, Copy, or Open in editor.
To sort only a subset of rows, keep them first with Filter CSV rows. To check two sorted exports against each other, use Compare CSV.
Choosing how values are compared
| Text (file2 before file10) | Natural, language-aware order: digit runs compare as numbers, so file2 comes before file10, and accented letters sort next to their base letter (ä near a). The page language sets the collation rules. |
|---|---|
| Text (character order) | Strict character-code order, predictable for codes and IDs, but file10 comes before file2, all digits come before letters, and ä comes after z. |
| Number | Plain decimal numbers such as -3, 0.25, 007 or 1e3, compared exactly, so 9007199254740993 sorts after 9007199254740992. Thousands separators, currency and units are not numbers. With Decimal separator set to Comma 1,5, 2,25 is read as two and a quarter. |
| Date | Dates in the selected Date format: ISO 2024-03-31 (optionally with a time, fractional seconds and a Z or +02:00 offset, converted to UTC), Day first 31/03/2024, Month first 03/31/2024 or 2024/03/31. |
Upper and lower case are treated as equal unless Match upper and lower case exactly is on. In natural order, equal-but-for-case values then keep their original order; with the option on, lowercase sorts before uppercase in English. Accents always count in natural order (resume and résumé differ).
Blanks, invalid values and ties
- The sort is stable: rows that compare equal on every key stay in the order they had in the file, in both directions.
- A cell that is empty or contains only spaces is a blank. Blanks follow Empty or non-matching values in both ascending and descending order.
- With Number or Date, values that can’t be read in the chosen format (
n/a,1,250,31/03/2024under ISO) are placed with the blanks, and a note says how many there are. - Only row order changes. Leading zeros, quotes, spaces and line breaks inside values are written back exactly; the header row stays first.
- A blank header is written as
Column 3, and a repeated header asname (2). Rows shorter than the header are padded with empty values. - The download keeps the file’s delimiter, line endings and final newline, and its encoding when that is UTF-8 (with or without a byte-order mark), UTF-16 LE or Windows-1252; other encodings are saved as UTF-8.
Troubleshooting
- 10 sorts before 9. The key compares as Text (character order). Choose Number, or Text (file2 before file10) for mixed labels such as
v10. - Some numbers are grouped with the blanks. They aren’t plain numbers: look for
1,250,€40,12 kgor a decimal comma with Point 1.5 selected. The note above the result gives the count. - Dates are in the wrong order. Day-first dates compared as text or with Month first 03/31/2024 are misread. Pick the format the file uses.
- Accented names land at the end. Use Text (file2 before file10) instead of character order.
Limits and privacy
Up to 20 sort columns. Files up to 25 MB, 100,000 rows, 250 columns and 2 million cells; for a larger file, split it first with Split CSV or filter out the rows you don’t need.
Sorting runs in your browser. The CSV is not uploaded to a server.
Example
Support tickets sorted by team (Text (file2 before file10), Ascending), then by priority (Number, Descending). 10 ranks above 2 because the key is numeric, the blank priority goes to the end of its team, Support and support count as the same team, and T-10 and T-11 tie on both keys, so they keep their original order.
ticket,team,priority,opened T-9,Billing,2,2024-05-03 T-10,Support,1,2024-05-01 T-2,Billing,,2024-05-02 T-11,support,1,2024-04-30 T-1,Billing,10,2024-05-04
ticket,team,priority,opened T-1,Billing,10,2024-05-04 T-9,Billing,2,2024-05-03 T-2,Billing,,2024-05-02 T-10,Support,1,2024-05-01 T-11,support,1,2024-04-30
Questions and answers
How do I sort by one column and then another?
Set the first column under Sort by, then select Add another column and choose the second under Then by. The second key only orders rows that tie on the first.
Why doesn’t sorting change my numbers or dates?
Values are parsed only to compare them. The output contains the same text as the input, so 007 and 2024-03-05T09:00+02:00 are written exactly as they were.
Can I sort by a custom order, like Low, Medium, High?
Not directly; the tool sorts by text, number or date. Add a column with a rank such as 1, 2, 3 in the CSV editor and sort by it as Number.