To sort text in Notepad++, open the file, drag-select the exact block of lines you want alphabetized, then choose Edit › Line Operations › Sort Lines Lexicographically Ascending (or Descending) — that menu command rearranges the selected region using a simple character comparison and leaves every other line untouched. The catch, and the reason most people say "it broke my file," is that the same command applied with no selection sorts the whole document silently, including code blocks, configuration keys, and blank rows you did not mean to touch. Notepad++ has no built-in numeric sort, no documented stable-sort guarantee, and no exact deduplication, so a list like file2, file10, file1 will come back as file1, file10, file2 unless you pad the numbers yourself. For a few hundred lines where one region is clearly defined, the menu is fast and reliable. For mixed fields, numeric labels, files above 50,000 lines, or any time you want to keep CRLF, drop blanks, or strip exact duplicates in the same pass, a dedicated browser sorter is the safer next step.

The Notepad++ sort menu and what each option actually does
Notepad++ exposes two sort commands under Edit › Line Operations. Sort Lines Lexicographically Ascending orders lines from A to Z using a byte-by-byte string compare, and Sort Lines Lexicographically Descending reverses that order. Both commands operate on whatever is currently selected. If the selection is empty, they operate on the entire open file. There is no numeric option, no case toggle, and no dialog to confirm the choice, which is why accidental sorts look like silent corruption: the file is changed the moment the menu item is clicked.
For most plain word lists and tag files this is fine. For anything where the line order matters semantically — YAML, INI, JSON arrays, CSV records, log sections separated by blank lines, or numbered filenames — an unguarded sort can move keys away from their sections and break parsers that read the file later. The fix is always the same: select first, then sort.
How to sort text in Notepad++ step by step
- Open the file in Notepad++ and put your cursor at the very first line you want alphabetized.
- Hold Shift and click at the end of the last line you want included. The selection should cover every line in the block and nothing else — partial selections on the first or last line leave those lines out of the sort.
- Confirm the selection by glancing at the status bar at the bottom; it shows the number of selected lines and characters. If it reads "Sel: 0 line", nothing is highlighted and the next click will sort the whole file.
- Open Edit › Line Operations › Sort Lines Lexicographically Ascending for A–Z, or Sort Lines Lexicographically Descending for Z–A.
- Save the file with Ctrl + S. If you want to keep the original alongside the sorted version, use File › Save As with a new name.
- Spot-check the first three and last three lines against what you expected, and skim the middle for any section headers or commented blocks that may have moved out of place.
If the block you sorted contains numeric prefixes such as file2 and file10, expect alphabetical not numerical order. Pad numbers to a constant number of places — file02, file10 — before sorting, or move the whole job to a tool that understands natural number order.
Three traps that quietly break a Notepad++ sort
The first trap is the empty-selection rule. Any time you click Sort Lines without highlighting anything, Notepad++ sorts the entire document, which scrambles code and config files whose lines only make sense in their original order. The second trap is that the menu uses plain string comparison, so lines starting with digits sort before letters and file10 lands before file2. The third trap is that Notepad++ treats the file as a flat sequence of physical lines; if your file is a CSV where a single logical record can span quoted newlines, sorting individual physical lines breaks the record structure even when each line is properly selected.
Two related gotchas come up often. Sorting is not guaranteed to be stable across versions, so two lines that compare equal today may swap order tomorrow after a Notepad++ update, and that matters if you plan to feed the sorted output into another tool. The menu also does not deduplicate, so apple and apple will both survive the sort. If you need to drop exact duplicates and keep the first one, see the duplicate-line workflow for Notepad++; if you want to combine that step with the sort itself, the browser tool described below does both in a single pass.
Move the job to a local browser sorter
When the Notepad++ menu is not enough — numeric labels, deduplication, large lists, or simply wanting a preview before you overwrite the original — the practical move is to copy the lines, switch to your browser, and use a dedicated Text Sorter that does everything locally. The tool accepts up to 1,000,000 UTF-16 code units and 50,000 logical lines, recognizes CRLF, CR, and LF as line endings, and never uploads anything. Sorting, trimming, blank-line removal, and exact-duplicate removal are independent toggles, so you can turn on only what you actually need and leave the rest of the lines exactly as they were.
Open the tool, paste the lines from your Notepad++ buffer, then choose ascending or descending order. If your list contains numbered labels such as chapter1, chapter2, chapter10, enable Natural number order so chapter2 sorts before chapter10. The comparison uses the browser's English Intl.Collator, the same collation standard documented for JavaScript's built-in Intl.Collator and Array.prototype.sort, so behavior is consistent across machines and reproducible as long as the browser version is the same.
Text Sorter controls at a glance
| Control | What it does | When to turn it on |
|---|---|---|
| Direction (Ascending / Descending) | Reverses the comparison result while keeping stable order for equal lines. | Always pick one. Descending does not simply flip a final array, so equal entries stay in their original relative position. |
| Case-sensitive comparison | Makes letter case participate in collation when on; off treats Apple and apple as equivalent. | On for code, identifiers, tags, and password lists; off for natural-language word lists. |
| Natural number order | Compares digit runs numerically so file2 beats file10. | On for filenames, chapter numbers, invoice IDs, and any list with embedded integers. |
| Trim every line | Strips leading and trailing Unicode whitespace before any other cleanup. | On when lines came from copy-paste and may carry stray spaces or tabs at the edges. |
| Remove empty lines | Drops lines that are empty after optional trimming. | On when blank rows slipped in from the source file. Note that a line containing only spaces counts as non-empty unless Trim is also on. |
| Remove exact duplicates | Keeps the first occurrence and discards later JavaScript-string-equal copies. | On when you want a clean unique list. "Apple" and "apple" remain separate even with case-insensitive sort. |
One thing the controls do not change is the character content of retained lines. Sorting alone does not add, remove, or rewrite characters; trimming only touches the edges; deduplication only removes whole lines. The output is rendered in full for review and downloadable as a UTF-8 text file. The downloaded file uses LF line endings regardless of whether the source was CRLF, CR, or a mix, so mixed input becomes consistent in the result.
Picking options that match the list you actually have
| Scenario | Recommended options | Why |
|---|---|---|
| Word list with mixed casing (e.g., Apple, banana, Cherry) | Ascending, case-sensitive off, Trim on, no numeric option | Treats Apple and apple as equivalent so the result groups correctly. |
| Numbered filenames (e.g., img1.png, img10.png, img2.png) | Ascending, Natural number order on, Remove exact duplicates on | Puts img2.png before img10.png and drops any accidental copies. |
| Inventory codes with leading spaces from copy-paste | Trim on, Remove empty lines on, then sort | Trimming runs first so a whitespace-only line becomes empty and can be dropped. |
| CSV column pasted as one value per line | Trim on, sort, no duplicate removal unless verified safe | CSV files are not safe to sort line by line if any field can contain quoted newlines; use a format-aware table tool for true CSV. |
| Large log section to alphabetize before saving | Ascending, Natural order on, preview first, then download | Preview the before/after counts so a duplicate-removal surprise cannot corrupt the file. |
The same inputs and options always produce the same line sequence because the browser collation is deterministic and the sort is stable, so equivalent lines keep their original relative order. That makes the tool useful for reproducible artifacts: paste the same buffer tomorrow, pick the same toggles, and you get the same output. If the sorted list will become part of a contractual or reproducible machine artifact, double-check that English browser collation matches the destination system's expectation — collation can differ from database ORDER BY behavior, operating-system filename order, and spreadsheet locale settings.
For the empty-line and deduplication case, the tool reports both the original logical line count and the final line count, so the difference you see is the number of lines removed by cleanup, not by sorting itself. Changing any input or option clears the old output immediately so a previous count cannot be confused with the new configuration. An input that exceeds the 1,000,000-character or 50,000-line limit is rejected before sorting, and no partial result is returned; if your file is bigger, the practical move is to split the file by line count in Notepad++, sort each chunk separately, and then recombine.