Skip to main content

CSV Sort

Order CSV data as text or numbers using the column you choose, then retrieve the sorted result directly in your browser.

  • Clipboard

Embed this widget

Customize the result, check the live preview, then copy the code.

Preview

Embed code type

Code to copy

Responsive and automatically resized by Bethemesh.

Names or numbers separated by commas

Was this tool useful?

How does this tool work?

Sorting CSV records gives an export a useful order without opening it in a spreadsheet that might reformat identifiers. Arrange a catalogue by category, a statement by amount or a list by several successive criteria. The tool moves complete records: cells stay attached to their row and source values are not converted in the resulting file. Choosing text or numerical comparison matters particularly for decimal prices, references containing leading zeros and dates written in local formats. A well-chosen ordering makes later checks easier while preserving the information in each record.

Enter exact column headings or positions starting at 1, separated by commas. Their order determines priority: category,price compares category first, using price only when categories tie. Ascending or descending direction and numerical mode apply to every key. The interface cannot request ascending categories and descending prices in the same pass. The header setting starts enabled, keeps that first record at the top and excludes it from sorting. Disable it when the file has no headings.

Text mode uses the browser's collation with digit sequences taken into account. A reference such as item2 can therefore precede item10 without becoming a number. Exact ordering of accented characters depends on the environment; it is not a universal binary order. Surrounding spaces are ignored initially, while case remains significant unless the corresponding option is enabled. These normalisations affect comparison keys only and do not rewrite exported cells. Repeated headings are best selected by position.

Numerical mode recognises simple decimal points or commas and valid thousands spaces. Empty and non-numerical cells follow numbers in either direction. Among themselves, they use text comparison in the selected direction. Equal numerical keys proceed to the next criterion; when every key ties, stable sorting retains input order. Reading detects commas, semicolons, tabs or vertical bars, respects quoted multiline fields and reuses the delimiter for output. Dates are never interpreted as calendar objects, so their suitability as sorting keys depends on their actual textual format.

How to use this tool

  1. Confirm the table headings

    Paste or import the CSV or TSV and check the header option. For repeated headings, numeric headings or names containing commas, identify the required positions rather than entering names.

  2. Set the priority of your criteria

    List columns from most important to least important. Select one common direction and the appropriate text or numerical mode. Adjust surrounding-space and case options to match the meaning of your keys.

  3. Inspect both ends of the ordering

    Run the sort and review records near the beginning and end, including ties. Check that references remain attached to their associated values before copying or exporting the ordered file.

Use cases

Arrange amounts for inspection

Use numerical mode to position decimal prices correctly while leaving missing values at the end, without rewriting how those amounts appear in the exported file.

Group catalogue entries visually

Sort by category and reference to bring related products together. The complete record moves with its descriptions, quantities and any other properties belonging to that product.

Prepare occurrence-based deduplication

Order an export before deduplication when input order determines which version survives. First confirm that the chosen chronological key can be compared correctly as text.

Examples

Order decimal prices numerically

Using price as the key with ascending numerical comparison puts 2.75 before 10.50 and leaves the empty cell last. Amounts keep their original spelling: comparison does not reformat the exported decimal values.

Input

item;price
A;10.50
B;2.75
C;

Result

item;price
B;2.75
A;10.50
C;

Resolve ties using a second key

Ascending text sorting on category,reference puts both A records before B. Within category A, digit-aware comparison places P2 before P10. The P2 reference belonging to category B remains attached to that category.

Input

category;reference
B;P2
A;P10
A;P2

Result

category;reference
A;P2
A;P10
B;P2

Tips and best practices

  • Do not assume dd/mm/yyyy dates sort chronologically as text: comparison begins with the day. Prepare an ISO yyyy-mm-dd key or use a transformation that understands the intended date format.
  • Amounts containing currency symbols, percentage signs or mixed separators are not automatically cleaned. Remove those markers in a separate step only when the cells genuinely represent comparable numbers.
  • Numerical mode applies to every selected column. For composite keys mixing text and numbers, inspect the output carefully or use successive stable passes, starting with secondary criteria and ending with the primary criterion.

Frequently asked questions

Does numerical sorting remove leading zeros?

No. It reads a number for comparison but preserves the original cell text. However, identifiers 001 and 1 become equal numerical keys. Choose text mode when retaining their distinction matters to the ordering.

Where do empty cells go in descending numerical order?

After numerical values, just as in ascending numerical order. Invalid text also follows numbers. This avoids treating missing values as zero or interleaving amounts with annotations that cannot be parsed as numbers.

Can each column have a different sorting direction?

Not within a single operation in this interface. One direction applies to all listed keys. Different directions can be achieved through stable passes, sorting the secondary criterion before the primary one.

Why can alphabetical order differ between computers?

Text mode uses the browser's available collation and natural digit comparison. Accented characters and punctuation may be ordered differently across environments. The tool does not promise an identical binary character order on every computer.

Related tools

Tools similar or complementary to this one.

Similar tools

Remove duplicate CSV rows using the columns you choose as matching criteria.

Data & spreadsheetsUse this tool

Filter CSV rows by column using text, exact values, or numeric conditions.

Data & spreadsheetsUse this tool

Select the CSV columns you want to keep in the final result.

Data & spreadsheetsUse this tool
GuideBest practicesBeginner

Split a CSV or Excel table into smaller files

Discover when to split a large table by row count or by a column value, and how to preserve a useful structure in every output file.

29 August 20261 min