92

I have lists of files that contain a few columns of data. It is not sorted the way I want from the output, so I'm manually hunting for where a line should be. Is there a way in Notepad++ to sort the lines alphabetically? If so, how?

  • 4
    Please see the new answer by @Franck Dernoncourt. People may be using the answer marked as accepted without reading about the update. – user33758 Feb 9 '15 at 0:57
  • 1
    @screener I saw it and up voted when I did. TextFX has other cool features too – Canadian Luke Feb 9 '15 at 1:15
  • 1
    Now that it is built into Notepad++ (Franck Dernoncourt's answer), perhaps accept that answer instead? – Peter Mortensen Jun 13 '16 at 10:58
  • @Peter I accepted the answer that worked best for me. I voted up the other answer as well – Canadian Luke Jun 13 '16 at 14:52
  • Possible duplicate of Sorting lines in Notepad++ without the TextFX plugin – trejder Sep 11 '18 at 6:13
134

Since Notepad++ 6.5.2 it is now natively possible to sort lines:

Version v6.9.2 (as of 8/5/16)

  • 2
    note that any capital comes before a lower case. ie. A-Z then a-z – Aequitas Jun 14 '15 at 0:05
  • 4
    Thanks for including a screenshot! This other post (superuser.com/questions/762279/…) is good, but it is very clear from your screenshot what to do. – Eric Hepperle - CodeSlayer2010 Nov 7 '15 at 19:55
  • 3
    It worked! This should be the accepted answer. – Peter Mortensen Jun 13 '16 at 10:57
  • 3
    This is buggy... I had to copy my text and paste into another tab to be able to sort... – Rosdi Sep 8 '16 at 6:56
  • 2
    I saw some problem with sorts, I think it can be linked with inconsistent line endings. One solution that helped me to solve the "non-sorting" issue was : Select all text, convert all line endings to Linux/Mac/Windows (whichever is NOT your operating system), then convert all line-endings to your operating system ending. Now It worked fine for me at this point. – Pacopaco Jun 5 '18 at 10:27
49

(Note that this answer was written before np++ 6.5.2 released.)

It seems that Notepad++ doesn't support sorting by default, but Notepad++ has many friends to do something like that for you which we call plugins.

  1. Download TextFX plugin for Notepad++ ( TextFX in SourceForge ) - go to the latest version and download the latest TextFX…bin.zip.
  2. Open the zip and extract NppTextFX.dll to (Program Files)\Notepad++\plugins folder.
  3. Restart Notepad++
  4. To do the sort, select lines to sort, go to TextFX on the main menu and select TextFX Tools - Sort lines.
  • No need to grab TextFX manually -> First: Update to newest version of NPP. Then pick "Plugins" / "Plugin Manager". It should then populate plugin list. Pick TextFX. "Install". Done. – bshea Aug 16 '17 at 16:25
  • Also, native sorting has improved over the years. (Pick "Edit"/"Line Operations") See other answers if you don't want to bother w/ TextFX plugin, though, I recommend it for other reasons.. – bshea Aug 16 '17 at 16:27
  • The plugin is now called "TextFX Characters". – Alek Davis Nov 9 '17 at 23:27
2

Since you are using Notepad++, I assume you are using Windows. You have a few other options to sort large text file content alphabetically.

My personal favorite is PowerShell. You could use the Sort-Object cmdlet. The following command shows an example of how to use the cmdlet. We first read the content (Get-Content) of MyFile.txt, pass it to the Sort-Object cmdlet (Sort) and output the result into a new file (Out-File).

Get-Content MyFile.txt | Sort | Out-File MySortedFile.txt

enter image description here

Another option is to use the sort command in the Command Prompt.

sort MyFile.txt /o MySortedFile.txt

enter image description here

Finally, the last option is to use an online tool: miniwebtool.com or sortlines.com will do the job.

  • 1
    Sorry, but he specifically asked about Notepad++. – user598527 Jul 24 '17 at 8:50

protected by Canadian Luke Sep 11 '18 at 21:06

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.