SORT CSV

Sort the rows of a CSV by one column or by up to five, each in its own direction. Numbers sort as numbers, dates sort as dates, and text sorts the way people expect, with 2 before 10. The header row stays on top and empty cells always go to the end.

Zero retention: your files never leave this browser. Verify it yourself in DevTools.

Loading the CSV tools.

About Sort CSV

How Can You Verify That Your Files Never Leave This Browser?

You do not have to take our word for it. Browser developer tools list every request a page makes, so you can watch 2csv work and confirm that your data is never sent anywhere. The check takes about a minute.

  1. Open your browser developer tools with F12, or Cmd+Option+I on a Mac, and select the Network tab.
  2. Reload the page and let it finish. You will see the page's own files (including the background file parser), its web fonts, and one anonymous page-view request. No file has been chosen yet, so none of them can contain your data.
  3. Click the clear icon in the Network tab so that the log is empty.
  4. Open a CSV file in the Sort CSV tool above, run it, and download the result.
  5. Look at the Network tab again. It is still empty. Reading, changing, and saving the file made no request at all. For extra proof, turn on offline mode after the page loads: every tool keeps working.

Your file is read into this tab's memory with the browser's own file reader, parsed and changed by code that is already on the page, and handed back to you as a download. It is never uploaded, never stored in the browser, and gone when you close the tab. The only other request the site can make is the feedback form, and only when you submit it.

The production site also sends a Content-Security-Policy header that tells your browser to refuse connections to anywhere except this site and the anonymous analytics endpoint, so even a bug could not send your data elsewhere.

How Do Multi-Level Sorts Work?

A multi-level sort orders rows by the first column you pick, then breaks ties using the second column, then the third, and so on, up to five levels. Sorting customers by state and then by last name is a two-level sort: every NY row stays together, and within NY the names run alphabetically.

  1. Add a level and choose its column.
  2. Choose the direction: A to Z or Z to A.
  3. Choose the type: Auto, Text, Number, or Date.
  4. Add more levels for tie-breaks, then apply.

How Does Auto Decide Between Text, Numbers, and Dates?

Auto looks at the values in the column. Values that read as numbers are sorted in number order, including money such as $1,250.00 and accounting negatives such as (15.00), which sort below zero. Values that read as dates sort in date order. Anything else sorts as text, ignoring upper and lower case.

  • Text uses natural number order, so item 2 comes before item 10.
  • Choose Text, Number, or Date yourself when a column mixes kinds and Auto guesses wrong.
  • Empty cells always go last, whichever direction you choose.

Does Sorting Keep the Original Order of Ties?

Yes. The sort is stable, which means rows that compare as equal on every level keep the order they had before. That matters when a file was already ordered by time or by entry, and you sort by a column such as state: within each state, the original order survives instead of being shuffled at random.

Can You Sort and Then Do Something Else?

Yes. The sort changes the table in this tab, and every other tool works on the sorted result. A common sequence is to sort by date, use Remove duplicates with Keep the last so the newest copy of each record survives, and export. Undo keeps the last five changes if a sort was not what you wanted.

The arrow in each grid header also sorts by that single column with one click. The Sort tool is the one to use when you need several levels or need to force a type such as Date on a column that Auto reads as text.

What Else Can You Do With a CSV Here?

  • CSV viewer: Open a CSV of any size, scroll every row, and see a profile of each column.
  • Filter CSV: Show only the rows that match an expression such as price > 10 AND state = "NY".
  • CSV validator: Find ragged rows, broken quotes, bad headers, encoding problems, and values of the wrong type.
  • Remove duplicates from CSV: Find and remove duplicate rows, comparing whole rows or only the columns you choose.
  • Trim CSV whitespace: Trim leading and trailing spaces, collapse double spaces, and drop invisible characters and empty rows.
  • Find and replace in CSV: Find text in one column or every column and replace it, with match case, whole cell, and regex options.
  • Remove rows from CSV: Delete rows by number or range, the first or last rows, empty rows, or rows that match a rule.
  • CSV editor: Edit cells, add or delete rows, and add, delete, rename, or move columns.
  • Split CSV column: Split one column into several at a delimiter, such as a full name into first and last.
  • Merge CSV columns: Join two or more columns into one with the separator you choose, skipping empty values.
  • CSV column type converter: Convert a column to clean numbers, ISO dates, true/false, or upper, lower, or title case.
  • CSV to JSON converter: Convert CSV to a JSON array of objects or arrays, or to JSON Lines, with typed values.
  • JSON to CSV converter: Convert a JSON array or JSON Lines to CSV, flattening nested objects into dotted column names.
  • CSV to SQL converter: Turn a CSV into SQL INSERT statements, with an optional CREATE TABLE, for PostgreSQL, MySQL, SQLite, or SQL Server.
  • CSV to TSV converter: Convert a comma-separated file to tab-separated values that paste cleanly into spreadsheets.
  • TSV to CSV converter: Convert a tab-separated file to a standard, properly quoted comma-separated CSV.
  • CSV splitter: Split a large CSV into smaller files of a set number of rows, with the header repeated in each.

All eighteen tools are on the 2csv home page, and once a file is open you can switch between them without reloading it. Part of the 2suite.io privacy-first ecosystem.

Frequently Asked Questions

Can I sort a CSV by more than one column?

Yes. Add up to five sort levels, each with its own column, direction, and type. Later levels only break ties left by earlier ones.

Why does 10 come after 9 instead of after 1?

Numbers sort as numbers, and text uses natural number order, so 2 comes before 10. Choose Text explicitly only if you want plain character order.

Where do empty cells go when sorting?

Empty cells always go last, in both A to Z and Z to A order, so blanks never crowd the top of the result.

Does sorting move the header row?

No. When First row is the header is on, the header stays on top and only the data rows are sorted.

Was this helpful?