ToolZoneX
Blog

Sort Text Lines

Sort a list of lines alphabetically, numerically (parsing each line as a number), or by length, with case-insensitive and remove-duplicates options.

Sorted Result

How to Use Sort Text Lines

Paste your list into the input box, one item per line, then choose a sort mode: Alphabetical sorts lines as text (A-Z or Z-A), Numerical parses each line as a number and sorts by its numeric value — so 10 correctly sorts after 2, unlike plain text sorting — and By Line Length sorts purely by how many characters are in each line, ignoring content. Toggle case-insensitive matching for alphabetical sorting, and optionally strip duplicate lines from the result before sorting.

Example

Sorting the lines 10, 2, and 33 alphabetically (as plain text) produces the order 10, 2, 33, because text comparison looks at the first character. Using Numerical mode instead correctly produces 2, 10, 33, since each line is parsed as an actual number before comparing.

Common Use Cases

  • Sorting a list of scores, prices, or IDs numerically instead of as plain text.
  • Alphabetizing a list of names or tags while removing duplicate entries in one pass.
  • Ranking lines by length, such as finding the shortest or longest entries in a list.

FAQs

  • Why does numerical sorting matter if I could just sort alphabetically? Plain text (lexicographic) sorting compares numbers character by character, so "10" is treated as coming before "2" because the character "1" is less than "2". Numerical mode instead parses each line into an actual number first, giving the mathematically correct order.
  • What happens to lines that aren't valid numbers in Numerical mode? Lines that can't be parsed as a number are pushed to the end of the ascending order (or the start in descending order), so your numeric lines still sort correctly among themselves.
  • Does Remove Duplicates consider case? Duplicate removal is exact-match — Apple and apple are treated as different lines unless they match exactly, so combine it with lowercase text beforehand if you need case-insensitive de-duplication.