Sort text by value in Notepad++

181,896

Solution 1

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

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

Solution 2

(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.

Solution 3

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.

Share:
181,896
Canadian Luke
Author by

Canadian Luke

Updated on September 18, 2022

Comments

  • Canadian Luke
    Canadian Luke 3 months

    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?

  • Franck Dernoncourt
    Franck Dernoncourt over 8 years
    @ScottRhee I updated for the same reason :)
  • Aequitas
    Aequitas over 7 years
    note that any capital comes before a lower case. ie. A-Z then a-z
  • Eric Hepperle - CodeSlayer2010
    Eric Hepperle - CodeSlayer2010 about 7 years
    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.
  • Peter Mortensen
    Peter Mortensen over 6 years
    It worked! This should be the accepted answer.
  • Rosdi
    Rosdi over 6 years
    This is buggy... I had to copy my text and paste into another tab to be able to sort...
  • Alex
    Alex about 6 years
    @Rosdi same for me...appreciate your comment.
  • Peter Mortensen
    Peter Mortensen about 6 years
    @Rosdi: What exactly isn't working? E.g., does it not sort at all?
  • Amit Tandel over 5 years
    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.
  • Amit Tandel over 5 years
    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..
  • Amit Tandel over 5 years
    STILL buggy and lacking case sensitivity clearly defined option. Why isn't this a feature? (case sensitivity ) (sort as decimal is workaround)? Really? It's a text editor that still has non-intuitive sorting issues. Hmm. I still prefer TextFX - it works and works fine.
  • unit5016
    unit5016 about 5 years
    The plugin is now called "TextFX Characters".
  • Pacopaco
    Pacopaco over 4 years
    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.
  • PeterCo
    PeterCo over 3 years
    @Pacopaco That's the only way it works for me. Without modifying the line endings (semicolons in my case), the sort does nothing.
  • Future over 2 years
    One can also use "Sort Lines As Number Ascending" if you have timestamps in front of your every log entry.
  • PeterCo
    PeterCo almost 2 years
    In Notepad++ Version v7.9.1 the long awaited feature was implemented as changelog point "15. Add case insensitive lines sorting."