Skip to main content
Developer helpers100% FreeInstant

CSV Sorter: Sort CSV Rows by Any Column

This free tool sorts the rows of a CSV table by one column. Pick the column by number or by header name, sort as text, numbers or natural order, and choose the direction. Quoted fields stay intact.

By Debmedia Technologies LLP · Kolkata, India · Updated

What Is It and When Do You Need It?

A CSV file is just text, but sorting it by hand is hard when cells hold commas or quotes. This tool sorts the rows safely.

Paste the CSV, name the column and choose the type.

How to Use This Tool

  1. Enter or paste your input in the box or boxes above.
  2. Choose the options, if there are any.
  3. Press the button to run the tool.
  4. Read the result and use the copy button where one is shown.

How the Calculation Works

The text is parsed into rows and cells with a state machine that understands quotes. The column is found by number or by matching the header name. The rows are sorted with a stable sort using text, numeric or natural comparison, then written back with quotes only where needed.

Worked Example

Sorting name,age / Bob,25 / Ann,30 / Cy,9 by age in descending order gives Ann (30), Bob (25) and Cy (9).

Common Uses

  • Cleaning exports.
  • Preparing data for review.
  • Ranking lists.
  • Putting names in order.

Tips and Common Mistakes

  • Count columns from 1.
  • Empty cells sort first in ascending order.
  • Use the CSV validator if the file looks broken.
  • Check the first result against a case you already know, so you can trust the tool for the rest.
  • Nothing you type leaves your device. The work is done by your browser, so it also works with a slow connection once the page has loaded.

Next, you may need the CSV validator, CSV and JSON converter, JSON formatter and validator, string escape and unescape tool.

Everything runs in your browser. Nothing you type is uploaded, stored or sent to any outside service.

Frequently Asked Questions

Text sorting puts 10 before 9, because it compares letter by letter. Number sorting uses the value.
A way of sorting names with numbers inside, so that file2 comes before file10.
Yes. The sort is stable, so rows with the same value keep their original order.
Yes. The file is read with a CSV parser and written back with correct quoting.

Disclaimer: results are calculated in your browser from the numbers you enter. Check important results before you rely on them for money, health, safety or legal decisions.