↕️

Line Sorter

Sort text lines alphabetically, numerically, or by length

Line Sorter — what it does

Sort lines alphabetically in either direction, numerically, or by length from shortest to longest, with options to ignore case and trim each line first. Declaring how the lines should be compared is what separates a correct sort from the familiar mess where 10 comes before 9.

Worked example

An attendee list sorted A → Z with the default settings (Ignore case and Trim lines both ticked). One line has a leading space and two names are typed in lowercase.

Input — attendee list

Chen Wei
  zoe martin
Adam Brown
Émile Durand
adams, lucy
Zhang Ling

Output — sorted A → Z

Adam Brown
adams, lucy
Chen Wei
Émile Durand
Zhang Ling
zoe martin

Trimming removed the leading space before "zoe martin", and the accented É sorts among the other E names instead of after Z.

When this tool helps

  • Alphabetising a list of names, tags or file paths before sharing it.
  • Sorting a list of numbers pasted from a report into ascending order.
  • Ordering lines by length to find the outliers in a list of values.

How to use it

  1. Paste the lines into the input box.
  2. Choose a sort mode: A to Z, Z to A, numeric or by length.
  3. Enable ignore case and trim as needed.
  4. Process and copy the sorted output.

Accuracy, limits, and good practice

  • Alphabetical sorting on numbers puts 100 between 10 and 11 — pick numeric mode whenever the lines are values rather than words.
  • Ignoring case gives a natural dictionary order; case-sensitive sorting groups all capitals before all lowercase letters.
  • Trimming matters more than it looks: a leading space sorts a line to the very top and looks like a bug in the output.

Frequently asked questions

How do I remove duplicates as well?

Sort first so duplicates sit together, then use the duplicate paragraph remover or a manual pass to drop them.

Where do blank lines end up?

They gather at one end depending on the mode. Remove them first if they should not appear in the result.

Does it handle non-English text?

Sorting follows standard string comparison, which is sensible for most scripts but may not match a language's dictionary conventions exactly.

What happens in numeric mode when some lines are not numbers?

Each whole line is read as a number. Lines that are valid numbers are sorted by value and placed first; lines that are not (for example "n/a" or "Invoice 12") are sorted alphabetically among themselves and placed after all the numbers. A line such as "1,250" is not a valid number because of the comma, so it lands in the text group.

Does the ignore-case option affect the length modes?

No. Shortest first and Longest first compare only the number of characters in each line (after trimming, if that option is ticked) and ignore the case setting entirely. Lines of equal length keep their original order.

Related tools on this site

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

文字行排序能做什麼

依字母正序或反序、依數值,或依長度由短到長排序文字行,並可選擇忽略大小寫與先修剪每行。有沒有明確宣告比較方式,正是「排序正確」與「10 排在 9 前面」那種熟悉混亂之間的差別。

實際範例

一份與會者名單以預設設定(忽略大小寫、修剪每行皆勾選)做 A → Z 排序。其中一行開頭有空格,兩個名字以小寫打字。

來源:與會者名單

Chen Wei
  zoe martin
Adam Brown
Émile Durand
adams, lucy
Zhang Ling

排序後:A → Z

Adam Brown
adams, lucy
Chen Wei
Émile Durand
Zhang Ling
zoe martin

修剪功能去掉了「zoe martin」前面的空格;帶重音的 É 會與其他 E 開頭的名字排在一起,而不是排到 Z 之後。

什麼時候用得上

  • 分享前把姓名、標籤或檔案路徑清單依字母排序。
  • 把從報表貼來的數字清單排成遞增順序。
  • 依長度排序,找出清單中長度異常的項目。

使用步驟

  1. 把文字行貼進輸入框。
  2. 選擇排序模式:A→Z、Z→A、數值或依長度。
  3. 視需要開啟忽略大小寫與修剪。
  4. 執行處理並複製排序結果。

精確度、限制與實務建議

  • 對數字用字母排序會讓 100 夾在 10 與 11 之間——當每行是數值而非文字時,請選數值模式。
  • 忽略大小寫可得到自然的字典順序;區分大小寫則會把所有大寫排在小寫之前。
  • 修剪比想像中重要:行首多一個空格就會被排到最前面,看起來像程式出錯。

常見問題

怎麼順便移除重複?

先排序讓重複相鄰,再用重複段落移除工具或手動清掉。

空行會排到哪裡?

依模式集中在其中一端。若不希望它們出現在結果中,請先移除。

支援非英文文字嗎?

排序依標準字串比較,對多數文字系統合理,但未必完全符合某語言的字典慣例。

數值模式下,遇到不是數字的行會怎樣?

每一整行會被當成一個數字來讀。能解析成數字的行依數值排序並排在前面;無法解析的行(例如「n/a」或「Invoice 12」)會在彼此之間依字母排序,並排在所有數字之後。像「1,250」這種含逗號的行不算有效數字,因此會落在文字那一組。

忽略大小寫的選項會影響長度模式嗎?

不會。「最短優先」與「最長優先」只比較每行的字元數(若勾選修剪則先修剪),完全不理會大小寫設定。長度相同的行會保持原本的先後順序。

本站相關工具

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