Glyph WidgetsGlyph Widgets
О проектеКонтактыБлогКонфиденциальностьУсловияПоддержать на Ko-fi

© 2026 Glyph Widgets. Все права защищены.

·

100% обработка на стороне клиента

Вернуться в блог

Text Sorter: Sort Lines, Remove Dupes

Text sorter orders lines alphabetically, numerically, by length, or naturally. Ascending and descending order supported. Free, no signup.

Glyph Widgets
27 февраля 2026 г.
10 min read
text sortersort lines onlinealphabetical ordersort text alphabeticallyline sorter

What Is the Text Sorter?

The Text Sorter is a browser-based tool that reorders lines of text using one of six sorting methods: alphabetical, numeric, by line length, natural sort, by word count, or by character count. Each method can run in ascending or descending order, and an optional case-sensitive toggle changes how uppercase and lowercase letters are ranked. Writers organising reference lists, developers sorting configuration keys or log entries, and data workers arranging exported values use this tool when they need reliable, multi-method line sorting without opening a spreadsheet or writing a script. All processing runs in your browser — your text never leaves your device — and the tool works offline after the initial page load.

Key Features

  • Alphabetical sorting (A–Z) — sorts lines using standard lexicographic order based on Unicode code points, case-insensitive by default.
  • Reverse alphabetical (Z–A) — the same alphabetical sort in descending order.
  • Numeric sorting — extracts and compares the leading numeric value of each line, handling integers and decimals correctly where pure alphabetical sort would fail.
  • Sort by line length — orders lines shortest-to-longest or longest-to-shortest by character count.
  • Natural sort — treats embedded numbers as numeric values rather than character sequences, so "item2" sorts before "item10" (unlike pure alphabetical sort which would put "item10" before "item2").
  • Sort by word count — ranks lines by how many space-separated words they contain.
  • Sort by character count — ranks lines by their total character count (equivalent to line length sort but exposed as a separate mode for clarity).
  • Ascending and descending order — toggle between these two orders for any sort type.
  • Case-sensitive option — when enabled, uppercase letters sort before lowercase (A before a); disabled by default so mixed-case text sorts as expected.
  • Batch mode — premium feature to sort multiple independent text blocks submitted one per line.
  • Copy result to clipboard — one-click copy of the sorted output.
  • Preset and history support — premium feature that saves your sort type, order, and case settings as a preset and records previous sorting operations.

How to Use the Text Sorter

Step 1: Open the Tool

Navigate to Text Sorter. The options panel at the top displays two rows of buttons: Order (Ascending / Descending) and Sort By (Alphabetical, Numeric, By Length, Natural, Word Count, Char Count). A "Case Sensitive" checkbox sits below. Ascending and Alphabetical are selected by default, with case sensitivity off.

Step 2: Choose Sort Type and Order

Click the sort type button that matches your data:

  • Alphabetical — for general text lists, names, words.
  • Numeric — for lines that begin with a number (prices, scores, IDs).
  • By Length — to rank lines by how long they are.
  • Natural — for versioned filenames, numbered items, or any list where embedded numbers should sort numerically.
  • Word Count — to rank lines from shortest to longest by number of words.
  • Char Count — to rank lines by total character count (same concept as By Length, surfaced separately).

Then click Ascending for smallest-to-largest / A-to-Z, or Descending for the reverse.

Step 3: Set Case Sensitivity (Optional)

By default, case sensitivity is off. This means "banana", "Banana", and "BANANA" sort identically relative to each other. Check the "Case Sensitive" box if you need uppercase letters to rank before their lowercase equivalents — for example, when sorting programming identifiers where case is semantically significant.

Step 4: Paste Your Input

Click the Input text area and paste your lines of text. The line count is displayed in small text above the text area. The Sorted Output panel on the right updates immediately with every keystroke. Changing the sort type, order, or case setting also instantly re-sorts the output.

Example: Alphabetical ascending, case insensitive:

Input:

cherry
Apple
banana
date

Output:

Apple
banana
cherry
date

Example: Numeric descending:

Input:

item: 42
item: 7
item: 100
item: 15

Output:

item: 100
item: 42
item: 15
item: 7

Step 5: Copy the Result

Click "Copy Result" to copy the sorted output to your clipboard. A toast notification confirms the copy. The button is disabled when the output is empty. The copy action also writes an entry to your tool history (supporter feature) with a label like Sort alphabetical asc (12 lines).

Practical Examples

Alphabetising a Reference List

A bibliography with 40 entries in random order needs to be alphabetised. Paste the entries — one per line — select Alphabetical and Ascending, and the output panel shows them in A-to-Z order. Copy and paste back into your document.

Sorting Version Numbers Correctly

A release notes file lists versions: v1.9, v1.10, v1.2, v1.11. Alphabetical sort would produce v1.10, v1.11, v1.2, v1.9 — wrong. Select Natural sort instead. Natural sort recognises that 10 > 9 numerically and produces v1.2, v1.9, v1.10, v1.11, which is correct.

Ranking Data by Value

You have a list of test scores, one per line:

87
42
95
61
78

Select Numeric and Descending to rank from highest to lowest:

95
87
78
61
42

Pure alphabetical sort would give 95, 87, 78, 61, 42 only by coincidence in this case, but would fail on a list that included both 9 and 10 (alphabetical gives 10 before 9).

Tips and Best Practices

Natural sort is usually the right choice for filenames and version strings. Alphabetical sort on strings like chapter1.txt, chapter10.txt, chapter2.txt produces the wrong order. Natural sort respects the embedded numbers and gives chapter1.txt, chapter2.txt, chapter10.txt.

Pair with Duplicate Line Remover before sorting. If your list contains duplicates, remove them first, then sort. This prevents identical lines from appearing adjacent in the output when you did not intend them to cluster.

Case sensitivity affects alphabetical sort only in predictable ways. With case sensitivity on, all uppercase lines sort before their lowercase equivalents because uppercase letters have lower Unicode code points than lowercase letters (A=65, a=97). If you want a fully case-insensitive sort, keep the option unchecked.

Numeric sort extracts the leading number. Lines that do not start with a number are sorted as if their numeric value is zero or are placed based on their position relative to zero. If your data has a mix of numeric-prefixed and non-numeric lines, numeric sort may produce unexpected groupings. Use alphabetical sort for mixed data.

The sorted output has the same number of lines as the input. The sorter does not remove duplicates or blank lines. A blank line sorts to the top in ascending alphabetical mode (empty string is less than any character). Combine with the Duplicate Line Remover if you also need deduplication.

Word Count sort is useful for trimming or prioritising list items. Sorting a list of feature descriptions by word count in ascending order quickly surfaces the briefest items, which are often the most concrete and scannable. Descending order surfaces the most verbose items for editing.

Common Issues and Troubleshooting

Numeric sort gives unexpected results. This sort type extracts the leading numeric value from each line using a number parse. Lines that do not start with digits are treated as zero. If your numbers are embedded mid-line (not at the start), use Natural sort, which finds numbers anywhere in the string and uses them to compare.

Alphabetical sort puts numbers before letters. When case sensitivity is off and the input has lines starting with digits, digits (0–9, Unicode 48–57) sort before uppercase letters (65+) and lowercase letters (97+). This is standard ASCII order. If you want numbers at the end, there is no built-in option for that; you would need to split and manually reorder sections.

Descending alphabetical sort reverses the entire list, including ties. Two lines that are equal (e.g., two blank lines) will appear in reversed input order relative to ascending sort. This is normal comparison sort behaviour.

The line count shown above each panel includes the trailing blank line. If your pasted text ends with a newline, the count may show one more line than you expect. This is because input.split('\n') counts the empty string after the final newline as a line. The sort handles it correctly; the extra blank line sorts to the top in ascending alphabetical mode.

Batch mode processes each batch-input line as an independent text block. Each line of the batch input is itself a block to sort. Since each "block" is a single line, batch mode with the standard sort types does not produce interesting results unless each batch-input line is itself a multi-line encoded block. Batch mode is most useful for the Duplicate Remover and Reverser tools.

Privacy and Security

The Text Sorter processes all text entirely within your browser using JavaScript. No text is transmitted to any server. The sortLines function runs synchronously on the text you provide; no network requests are made during sorting. The tool works offline after the initial page load. Sorting confidential data — internal reports, personal lists, sensitive identifiers — carries no risk of that data leaving your device.

Frequently Asked Questions

Is the Text Sorter free? Yes. All six sort types, both order directions, and the case sensitivity option are free with no account or payment required.

Does it work offline? Yes. Once the page has loaded, sorting works without an internet connection.

Is my text sent to a server? No. All sorting runs in your browser. Your text never leaves your device.

What is the difference between Alphabetical and Natural sort? Alphabetical sort compares characters one by one using their Unicode code points, so "item10" sorts before "item2" because "1" (49) < "2" (50) at the third character. Natural sort recognises the embedded numbers 10 and 2, compares them numerically, and correctly places "item2" before "item10".

What does "By Length" sort on? By Length sorts on the total character count of each line, including spaces. A line with 20 characters sorts before a line with 21 characters in ascending mode.

How is Word Count sort different from By Length? Word Count sorts by the number of space-separated tokens in each line. A short line with four long words may rank higher than a longer line with two short words. By Length ignores word boundaries and counts raw characters.

Does the tool handle tabs or other whitespace in lines? The sortLines function splits input on newlines (\n). Tabs and other whitespace within a line are part of that line's content and affect length-based and word-count sorts (a tab-separated line may have more "words" depending on how the word count is computed). For clean sorting, normalise whitespace before pasting.

Can I sort in place without a side-by-side view? The current UI always shows a side-by-side input/output layout. To replace your input with the sorted output, copy the result and paste it back into the input panel. The output will re-sort from the new input instantly.

What happens to blank lines during sorting? Blank lines are treated as lines with zero characters and empty strings. In ascending alphabetical sort they float to the top. In descending alphabetical sort they sink to the bottom. They are not removed by the sorter; use the Duplicate Line Remover if you want to collapse multiple blank lines.

Is there a maximum number of lines the tool can sort? No enforced maximum. Sorting is fast even for thousands of lines. Very large inputs — hundreds of thousands of lines — may take a moment, but most practical use cases sort instantaneously.

Related Tools

  • Duplicate Line Remover — remove exact or near-duplicate lines before or after sorting to produce a clean, unique list.
  • Word Counter — count words, characters, sentences, and paragraphs in the text before or after sorting.
  • Text Reverser — reverse the character, word, or line order of your text using a different transformation than sorting.

Try the Text Sorter now: Text Sorter

Последнее обновление: 27 февраля 2026 г.

Продолжить чтение

Ещё статьиПопробовать Text Sorter