Sorting lines in Notepad++ without the TextFX plugin

241

44

The current version of Notepad++ (at the time of this writing) is 6.6.3. Version 6.5.2 is the first that introduced a native (without a plugin) sorting function. At least, that's what they claim; even though we're nine releases after version 6.5.2, I have found nothing about this feature:

  • There is no sign of it in the menu (or I am blind),
  • There isn't even a word in Notepad++ documentation (online help).

Everything I read around the Internet (including this answer) still talks about sorting lines using the TextFX plugin. There isn't anything about a native (QuickSort-based) function.

So: How do I sort lines in Notepad++ without using the TextFX plugin?

trejder

Posted 2014-06-01T11:39:15.383

Reputation: 8 427

Answers

369

The proper menu option is as follows.

For all versions prior to 6.8.3:

Menu EditLine OperationsSort Lines in Ascending / Descending Order

For version 6.8.3 and following:

Menu EditLine OperationsSort Lines Lexicographically Ascending / Descending

Select a few lines and your selection will be sorted. If there's no selection, your entire file will be sorted.

trejder

Posted 2014-06-01T11:39:15.383

Reputation: 8 427

1Can't believe I've used Notepad++ for this long without knowing about this! – Jay Cummins – 2016-08-03T13:58:39.717

3For some weird reason this didn't work for me. I'm on Windows but my text had LF line endings only (text pasted from browser). To work around it I had to convert all Line endings to Unix, then back to Windows, then the sort worked. – pgr – 2017-01-26T12:51:35.417

@pgr Notepad++ sorting mechanism should work on any line ending. If you can reproduce this behavior then this may classify as a bug. – trejder – 2017-01-27T18:39:25.393

1@trejder The fact that I had to convert one way and then back tells me the real problem is Notepad++'s realization of what kind of document it's working with. Maybe pasted text that hasn't been saved yet is an edge case. But it's definitely a bug, yes. – pgr – 2017-01-28T10:33:46.917

This worked for me with 7.3.3. However, had to do Edit > Convert CASE to > lowercase as the first step. Used the feature to sort a huge list of email addresses, so not a case-sensitive scenario. – Razvan Zoitanu – 2017-05-17T15:56:32.923

3

The next question could be whether it is possible to sort in a case-insensitive way...

– Peter Mortensen – 2018-07-20T12:50:53.793

Not working for me! – Black – 2018-09-10T07:57:47.050

@PeterMortensen The next goof question could be, why you asked that question on Stack Overflow, not on Super User? :> – trejder – 2018-09-11T06:14:13.907

1The sort function is not working correctly, it sorts like this: addCartLink bindPager setItemsTitle addTab – Black – 2018-10-09T14:10:57.737

1As of 7.5.9, this function is flat out broken and does nothing on my lines. – Collin Chaffin – 2019-02-04T13:18:08.090

1I noticed that the sort function only works when lines are separated by both a Carriage Return and Line Feed, in that order. Using only one or the other will not allow for sorting, probably because Notepad thinks it's all one line. – Tharkon – 2019-05-21T11:31:13.543

1V7.8.1 still works, , but french menu are "Édition/Ligne/Trier les lignes ..." – pdem – 2019-12-12T08:07:33.527

@Tharkon AFAIK Notepad++ supports all three line endings (Windows, Linux and Mac) so it is hard for me to believe that they have designed sorting function for only one of them. But I haven't got chances to test this, sorry. – trejder – 2019-12-12T08:57:06.580