Sort text by value in Notepad++

93

14

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?

Canadian Luke

Posted 2014-03-03T22:55:01.573

Reputation: 22 162

4Please see the new answer by @Franck Dernoncourt. People may be using the answer marked as accepted without reading about the update. – None – 2015-02-09T00:57:00.307

1@screener I saw it and up voted when I did. TextFX has other cool features too – Canadian Luke – 2015-02-09T01:15:31.600

1

Now that it is built into Notepad++ (Franck Dernoncourt's answer), perhaps accept that answer instead?

– Peter Mortensen – 2016-06-13T10:58:49.393

@Peter I accepted the answer that worked best for me. I voted up the other answer as well – Canadian Luke – 2016-06-13T14:52:14.153

Possible duplicate of Sorting lines in Notepad++ without the TextFX plugin

– trejder – 2018-09-11T06:13:19.767

Answers

141

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

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

Franck Dernoncourt

Posted 2014-03-03T22:55:01.573

Reputation: 13 518

1@ScottRhee I updated for the same reason :) – Franck Dernoncourt – 2014-08-26T23:57:20.613

2note that any capital comes before a lower case. ie. A-Z then a-z – Aequitas – 2015-06-14T00:05:28.647

4

Thanks for including a screenshot! This other post (http://superuser.com/questions/762279/sorting-lines-in-notepad-without-the-textfx-plugin) is good, but it is very clear from your screenshot what to do.

– Eric Hepperle - CodeSlayer2010 – 2015-11-07T19:55:29.860

3It worked! This should be the accepted answer. – Peter Mortensen – 2016-06-13T10:57:51.590

3This is buggy... I had to copy my text and paste into another tab to be able to sort... – Rosdi – 2016-09-08T06:56:25.207

@Rosdi same for me...appreciate your comment. – Alex – 2016-09-27T12:04:15.503

1@Rosdi: What *exactly* isn't working? E.g., does it not sort at all? – Peter Mortensen – 2016-12-17T17:22:08.990

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. – bshea – 2017-08-16T16:33:29.123

2I 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 – 2018-06-05T10:27:15.250

@Pacopaco That's the only way it works for me. Without modifying the line endings (semicolons in my case), the sort does nothing. – PeterCo – 2019-03-26T09:38:47.813

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.

Scott Rhee

Posted 2014-03-03T22:55:01.573

Reputation: 1 923

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 – 2017-08-16T16:25:22.423

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 – 2017-08-16T16:27:58.493

The plugin is now called "TextFX Characters". – Alek Davis – 2017-11-09T23:27:44.353

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.

Martin

Posted 2014-03-03T22:55:01.573

Reputation: 435

1Sorry, but he specifically asked about Notepad++. – user598527 – 2017-07-24T08:50:48.100