Text tool

Text Sorter

Reorder lines of text alphabetically or numerically with fine-grained control over whitespace and case sensitivity.

Output

How the sort controls work

The sort dropdown offers four modes. A–Z sorts lines in alphabetical order using locale-aware comparison, so special characters and accented letters position themselves according to your system language. Z–A reverses that order. Numeric ascending treats lines as decimal numbers and sorts from smallest to largest; lines containing non-numeric text sort after the numeric ones. Numeric descending reverses the numeric order.

Three checkboxes modify the sort. Ignore case, enabled by default, makes "Alpha" and "alpha" equivalent in alphabetical modes, so capitalization does not affect sort order. Trim lines, disabled by default, removes leading and trailing whitespace from each line, and those trimmed lines are what the output contains. Preserve blank lines, also disabled by default, keeps empty lines in place; when unchecked, the sorter removes all blank lines. The output area shows the sorted result, and a copy button lets you take the result to your clipboard.

Sorting a mixed filename list

  • Input: file1, file10, file2, file20, file3
  • Alphabetical mode (A–Z): file1, file10, file2, file20, file3 — "1" sorts before "2" as a string character
  • Numeric mode ascending: file1, file2, file3, file10, file20 — the numeric suffix drives the order
  • Numeric mode descending: file20, file10, file3, file2, file1 — highest numbers first
  • With Trim lines enabled, " file5 " and "file5 " both become "file5", sort as equals, and appear in the output without the stray spacing

Alphabetical sorting with case and numeric sensitivity

Both alphabetical modes use locale-aware comparison with numeric handling, so "file2" sorts before "file10" even in A–Z mode, because runs of digits inside each line are compared as numbers rather than character by character. This hybrid behavior matches how humans naturally sort filenames. Turning off Ignore case adds case to the comparison, so "Alice" and "alice" stop counting as equal and are ordered by your locale's casing convention.

A practical example: sorting a list of email addresses with various cases and domain variations. If Ignore case is on, "alice@example.com" and "ALICE@example.com" are treated as identical in sort order, maintaining their original relative position (a stable sort). If Ignore case is off, uppercase letters sort first, so "ALICE@example.com" comes before "alice@example.com", even if they are otherwise the same.

Common sorting scenarios

  • Invoice numbers from a spreadsheet: paste a column of IDs like "INV-001", "INV-010", "INV-002", enable Trim lines, and sort A–Z. The digit-aware comparison orders the numeric suffixes correctly: INV-001, INV-002, INV-010.
  • Alphabetized contact list: use A–Z with Ignore case on to sort names regardless of how they were typed, then export to a properly formatted directory.
  • Deduplicating and ordering: use A–Z with Trim and Preserve blank lines on, so identical trimmed lines end up adjacent and you can manually remove duplicates before export.
  • Reverse chronological list: paste dates in YYYY-MM-DD format and use Z–A to show the most recent first, since that format sorts correctly as text.
  • Mixed-case dataset validation: turn Ignore case off to see if your source has inconsistent capitalization that should be standardized before processing.

Frequently asked questions

Why does Numeric ascending put non-numeric lines last?

Lines containing text or symbols cannot be converted to finite numbers, so the algorithm places numeric lines first, sorted by value, and keeps non-numeric lines after them in their original relative order.

What happens if I sort with Trim but the trimmed lines are identical?

If two lines become identical after trimming, their original order is preserved (a stable sort). The sorter does not remove duplicates, only reorder them.

Can I sort by a substring, like the middle of each line?

Not directly. This tool sorts from the start of each line. If you need to sort by a middle substring, use your spreadsheet software or a text editor with regex find-and-replace to move that substring to the start, sort, then move it back.

Does Trim modify the actual text in the output?

Yes. Trim removes each line's leading and trailing whitespace before sorting, and the output contains the trimmed lines. A line that started with three spaces comes out with none, so leave Trim off when indentation matters.

How is "numeric ascending" different from "A–Z" with Ignore case on?

A–Z performs alphabetical comparison where digits are sorted as numerals within the text (so file2 comes before file10). Numeric ascending attempts to parse each entire line as a decimal number and sorts by the parsed value, placing non-numeric lines last.

What does a stable sort mean?

When two lines compare as equal (such as after trimming or case-insensitive comparison), they stay in their original relative order instead of being rearranged. This is useful when you want to preserve the sequence of identical or nearly identical records.