↕

CSV Sorter

Sort CSV rows by a text, number, or date column

No file selected.

CSV Sorter — what it does

Sort rows by any column, telling the tool whether to treat the values as text, numbers or dates, and in ascending or descending order. Declaring the type is what separates a correct sort from the classic spreadsheet failure where 100 lands between 10 and 11 because the column was compared as text.

Worked example

Orders sorted by unit_price as Number, Descending, to see the most expensive items first.

Input — orders.csv

order_id,region,product,qty,unit_price,order_date
1001,East,Notebook,12,3.50,2026-01-04
1002,West,Stapler,3,8.99,2026-01-04
1003,East,Notebook,5,3.50,2026-01-05
1004,North,Pen box,20,2.10,2026-01-06
1005,West,Notebook,7,3.50,2026-01-06
1006,East,Stapler,1,8.99,2026-01-07
1007,North,Pen box,15,2.10,2026-01-08
1008,West,Desk lamp,2,24.00,2026-01-08

Output — sorted.csv

order_id,region,product,qty,unit_price,order_date
1008,West,Desk lamp,2,24.00,2026-01-08
1002,West,Stapler,3,8.99,2026-01-04
1006,East,Stapler,1,8.99,2026-01-07
1001,East,Notebook,12,3.50,2026-01-04
1003,East,Notebook,5,3.50,2026-01-05
1005,West,Notebook,7,3.50,2026-01-06
1004,North,Pen box,20,2.10,2026-01-06
1007,North,Pen box,15,2.10,2026-01-08

Rows with equal prices (the three Notebook rows at 3.50) keep their original order relative to each other. The download is always sorted.csv.

When this tool helps

  • Ordering a transaction export by date before splitting it into periods or deduplicating by latest record.
  • Ranking products, campaigns or regions by a numeric measure to find the top and bottom performers.
  • Alphabetising a name or reference list before printing or handing it over.

How to use it

  1. Choose the CSV file.
  2. Select the sort column and its data type.
  3. Choose ascending or descending order.
  4. Process and download the sorted CSV.

Accuracy, limits, and good practice

  • Choosing number on a column containing text places non-numeric values inconsistently — profile the column first if you are unsure it is clean.
  • Date sorting depends on parseable dates; run the date normaliser first when the column mixes several formats.
  • Sorting rewrites row order permanently in the output, so keep the original if the source sequence carries meaning.

Frequently asked questions

Can I sort by two columns?

Sort by the secondary column first, then by the primary one. A stable sort preserves the earlier order within equal values.

Where do blank values go?

They group together at one end of the order. Clean or filter them first if their position matters for a report.

Is text sorting case-sensitive?

Text comparison follows standard string ordering, so mixed capitalisation can group unexpectedly. Normalise case first for a strict alphabetical list.

How are thousands separators and currency symbols handled in Number mode?

Commas inside a value are removed before comparing, so 1,250 sorts as 1250. A currency symbol is not removed and makes the value unparseable; such rows are moved to the end of the file in both Ascending and Descending order.

How does Date mode read the values?

With the browser's own date parser: ISO dates such as 2026-01-04 and forms like March 7, 2026 work, but day-first dates such as 15/03/2026 are not understood and go to the end as unparseable. Run mixed columns through the CSV date normalizer first.

Related tools on this site

Everything above runs inside this page. CSV Sorter needs no account, no upload, and no server round trip — close the tab and nothing is left behind.

CSV 排序工具能做什麼

依任一欄位排序資料列,並指定該欄要當作文字、數字或日期比較,同時選擇遞增或遞減。有沒有宣告型別,正是正確排序與經典試算表災難的分野——後者會因為以文字比較,把 100 排在 10 與 11 之間。

實際範例

訂單依 unit_price 以「數字」「遞減」排序,先看最貴的品項。

來源:orders.csv

order_id,region,product,qty,unit_price,order_date
1001,East,Notebook,12,3.50,2026-01-04
1002,West,Stapler,3,8.99,2026-01-04
1003,East,Notebook,5,3.50,2026-01-05
1004,North,Pen box,20,2.10,2026-01-06
1005,West,Notebook,7,3.50,2026-01-06
1006,East,Stapler,1,8.99,2026-01-07
1007,North,Pen box,15,2.10,2026-01-08
1008,West,Desk lamp,2,24.00,2026-01-08

得到:sorted.csv

order_id,region,product,qty,unit_price,order_date
1008,West,Desk lamp,2,24.00,2026-01-08
1002,West,Stapler,3,8.99,2026-01-04
1006,East,Stapler,1,8.99,2026-01-07
1001,East,Notebook,12,3.50,2026-01-04
1003,East,Notebook,5,3.50,2026-01-05
1005,West,Notebook,7,3.50,2026-01-06
1004,North,Pen box,20,2.10,2026-01-06
1007,North,Pen box,15,2.10,2026-01-08

價格相同的列(三筆 3.50 的 Notebook)彼此維持原本的先後。下載檔一律叫 sorted.csv。

什麼時候用得上

  • 在依期間拆分或保留最新紀錄之前,先把交易匯出檔依日期排序。
  • 依數值指標為產品、活動或地區排名,找出表現最好與最差者。
  • 列印或交付前,先把名單或參考清單依字母順序排好。

使用步驟

  1. 選擇 CSV 檔案。
  2. 選定排序欄位與其資料型別。
  3. 選擇遞增或遞減。
  4. 執行處理並下載排序後的 CSV。

精確度、限制與實務建議

  • 對含文字的欄位選「數字」會讓非數值資料的位置變得不一致;不確定欄位是否乾淨時請先做欄位統計。
  • 日期排序需要可解析的日期,欄位混雜多種格式時請先用日期格式統一工具處理。
  • 排序會永久改寫輸出的列順序,若原始順序本身具有意義,請保留原始檔。

常見問題

可以用兩個欄位排序嗎?

先依次要欄位排序,再依主要欄位排序。穩定排序會在相同值中保留前一次的順序。

空白值會排到哪裡?

會集中在順序的一端。若其位置會影響報表,請先清理或篩除。

文字排序區分大小寫嗎?

文字比較採標準字串順序,因此大小寫混雜時可能分群異常。需要嚴格字母序請先統一大小寫。

數字模式下,千分位與貨幣符號怎麼對待?

值裡的逗號會先被去掉再比較,所以 1,250 以 1250 排序。貨幣符號不會被去掉,會讓該值無法解析;這類列在遞增與遞減時都被排到檔案最後。

日期模式怎麼讀值?

交給瀏覽器本身的日期解析器:2026-01-04 這類 ISO 日期與 March 7, 2026 這類寫法都可以,但 15/03/2026 這種日在前的寫法看不懂,會被當成無法解析而排到最後。混雜格式的欄位請先經過「CSV 日期格式統一」工具。

本站相關工具

以上步驟全部在這個頁面內完成,CSV 排序工具 不需要註冊、不上傳檔案、也不經過伺服器,關閉分頁後不會留下任何資料。