Line sorting not working in some cases

  • Hi all,
    the problem I have is that if I try to sort lines separated by just \n (instead of \r\n), Notepad++ doesn’t sort them because it sees them like a single block.

    In my opinion lines separated by just \n should be considered independent lines. Do you agree? Is it a bug?

  • @niente0

    Nope, no bug.

    It breaks the lines according to what your status bar says the line endings are.
    Example of that:

    If you mix line ending types in your file, this is a bad thing that you shouldn’t do. And yes, if that’s the case it will not sort like you want it to.

    The cure is to convert line endings to a different type than you want, then convert back to the type you do want. Then you are safe to proceed with your sort. See Edit menu > EOL Conversion

  • @niente0 ,

    FYI, the next release of the (which will go live after Notepad++ v7.9.6 releases) will include an extra description on the line-sorting features, making what @Alan-Kilborn more obvious to those who actually look at the usermanual:

    NOTE: Sorting is performed with the assumption that all line-endings in the file are uniform and match the current selection for the file being edited – the quickest way to check that selection is to glance at the status bar, where the current line-ending type is shown either as Windows (CR LF), Unix (LF) or Macintosh (CR). It might be desirable to check the line-ending types in your file before executing a sorting operation.

  • @PeterJones

    Cool that that kind of thing made it into the manual.
    Manual is getting better and better all the time.

    Does it go far enough, though?
    Maybe it should also say what I said, how to convert the lines.

    Nah, it’s OK, that would be redundant documenting because I’m sure there is also an independent place where EOL conversion is discussed.

  • @Alan-Kilborn ,

    Maybe it should also say what I said, how to convert the lines.

    So the sort and duplicates EOL paragraphs now direct you to read EOL Conversion to find out how to do the fix, and the EOL Conversion paragraph mentions converting once or twice to fix the mixed-eol situation.

Log in to reply