Search code examples
notepad++

Why aren't the lines sorted as expected in Notepad++?


I have these lines:

'RECIPIENT_REFUSED',
'DELIVERED',
'DELIVERING_TO_DESTINATION',
'DRIVER_CONFIRMATION_PENDING',
'IN_PAYMENT',
'NOT_PAID',
'PAID',
'QUOTE_EXPIRED',
'QUOTE_REJECTED',
'QUOTE_UNDECIDED',
'TIME_CHANGED'
'ARRIVED_AT_DESTINATION',
'ARRIVED_AT_PICKUP',
'CANCELLED_BY_RECIPIENT',
'CANCELLED_BY_XXX',
'CANCELLED_BY_SHOP',
'CANCELLED_BY_TRANSPORT',
'DISPATCH_PENDING',
'DRIVING_TO_PICKUP',
'ITEMS_PICKED_UP',
'RECIPIENT_ABSENT',

Marking all of them and then running the Edit | Line Operations | Sort Lines Lexicographically* (what ever option I select) doesn't sort the above lines properly. This is the result after a lexicographically ascending sort:

'ARRIVED_AT_DESTINATION',
'ARRIVED_AT_PICKUP',
'CANCELLED_BY_RECIPIENT',
'CANCELLED_BY_XXX',
'CANCELLED_BY_SHOP',
'CANCELLED_BY_TRANSPORT',
'DISPATCH_PENDING',
'DRIVING_TO_PICKUP',
---- Below this line the sort order is wrong but it doesn't change
---- when I re-run the sort functions
'ITEMS_PICKED_UP',             
'RECIPIENT_ABSENT',            
'RECIPIENT_REFUSED',           
'DELIVERED',                   
'DELIVERING_TO_DESTINATION',   
'DRIVER_CONFIRMATION_PENDING', 
'IN_PAYMENT',
'NOT_PAID',
'PAID',
'QUOTE_EXPIRED',
'QUOTE_REJECTED',
'QUOTE_UNDECIDED',
'TIME_CHANGED'

Am I doing something wrong, do I misunderstand the output of these functions, is my Notepad++ installation not configured properly or is it a Notepad++ bug? Any idea/hint?

Notepad++ 7.9.5 and these installed plugins:

  • Mime tools 2.5
  • Npp Converter 4.2.1
  • NppExport 0.2.9

Update:

No hidden characters. This is an ENUM list from MySQL which I want to have sorted. All other tools sort it correctly.


Update:

Here the screenshot from NP++ showing all characters.

enter image description here


Update:

How to reproduce it:

This is the list copied from phpMyAdmin from the ENUM table field into an empty NP++ tab:

'ARRIVED_AT_DESTINATION', 'ARRIVED_AT_PICKUP', 'CANCELLED_BY_RECIPIENT', 'CANCELLED_BY_SFD', 'CANCELLED_BY_SHOP', 'CANCELLED_BY_TRANSPORT', 'DISPATCH_PENDING', 'DRIVING_TO_PICKUP', 'ITEMS_PICKED_UP', 'RECIPIENT_ABSENT', 'RECIPIENT_REFUSED', 'DELIVERED', 'DELIVERING_TO_DESTINATION', 'DRIVER_CONFIRMATION_PENDING', 'IN_PAYMENT', 'NOT_PAID', 'PAID', 'QUOTE_EXPIRED', 'QUOTE_REJECTED', 'QUOTE_UNDECIDED', 'TIME_CHANGED'

Then I replace all , with ,\n because Line Split doesn't split the lines.

The split lines are then sorted in this strange way.


Solution

  • As user 41686d6564 pointed out it's the problem with my previously line split where I use for Windows document the Linux EOL.

    It can be fixed with one of these 2 options:

    1. Changing the EOL of the document to Linux when I use ,\n for the replacement.
    2. Using ,\r\n if the document is in the Windows mode.