<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Cannot sort lines ending with \n or \r only]]></title><description><![CDATA[<p dir="auto">Hi, I cannot sort lines terminating with just the “<strong>\n</strong>” or “<strong>\r</strong>” characters.<br />
If they end with “<strong>\r\n</strong>” the sort command works correctly.<br />
Could you please fix this?<br />
Thank you</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/23176/cannot-sort-lines-ending-with-n-or-r-only</link><generator>RSS for Node</generator><lastBuildDate>Sun, 08 Nov 2026 03:02:42 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/23176.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 28 Jun 2022 08:06:11 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Cannot sort lines ending with \n or \r only on Tue, 28 Jun 2022 18:47:46 GMT]]></title><description><![CDATA[<p dir="auto">I made a suggestion for a replacement function for <code>stringSplit()</code>, to allow proper handling of mixed line-endings in the sort, but I did it <a href="https://github.com/notepad-plus-plus/notepad-plus-plus/issues/7735#issuecomment-1169095040" rel="nofollow ugc">HERE</a> rather than, well, here.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/77995</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/77995</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Tue, 28 Jun 2022 18:47:46 GMT</pubDate></item><item><title><![CDATA[Reply to Cannot sort lines ending with \n or \r only on Tue, 28 Jun 2022 14:24:39 GMT]]></title><description><![CDATA[<p dir="auto">Sorting happens <a href="https://github.com/notepad-plus-plus/notepad-plus-plus/blob/3a2ef5cff99adc309abed46acc2c7df37212e0ba/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp#L3727" rel="nofollow ugc">HERE</a> in the Notepad++ source code.</p>
<p dir="auto">The data is divided into a sortable list of lines based on the current end-of-line setting with this:</p>
<p dir="auto"><code>std::vector&lt;generic_string&gt; splitText = stringSplit(text, getEOLString());</code></p>
<p dir="auto">Looking into the <a href="https://github.com/notepad-plus-plus/notepad-plus-plus/blob/3a2ef5cff99adc309abed46acc2c7df37212e0ba/PowerEditor/src/MISC/Common/Common.cpp#L747" rel="nofollow ugc">stringSplit</a> function, we can see that the lines of a file are decided based upon exactly and only the single line-ending type that is the file’s end-of-line type:</p>
<pre><code class="language-cpp">std::vector&lt;generic_string&gt; stringSplit(const generic_string&amp; input, const generic_string&amp; delimiter)
{
	size_t start = 0U;
	size_t end = input.find(delimiter);
	std::vector&lt;generic_string&gt; output;
	const size_t delimiterLength = delimiter.length();
	while (end != std::string::npos)
	{
		output.push_back(input.substr(start, end - start));
		start = end + delimiterLength;
		end = input.find(delimiter, start);
	}
	output.push_back(input.substr(start, end));
	return output;
}
</code></pre>
<p dir="auto">For the OP’s desire to happen, a new version of the stringSplit function would be needed to where the 3 types of possible line-endings are looked for, and then the exact line-ending of every given line would need to be retained (at the end of each string) in the list of strings generated by the function.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/77987</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/77987</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Tue, 28 Jun 2022 14:24:39 GMT</pubDate></item><item><title><![CDATA[Reply to Cannot sort lines ending with \n or \r only on Tue, 28 Jun 2022 13:10:09 GMT]]></title><description><![CDATA[<p dir="auto"><a href="https://github.com/notepad-plus-plus/notepad-plus-plus/issues/7735#issuecomment-1168473362" rel="nofollow ugc">THIS</a> is also a comment by <a class="plugin-mentions-user plugin-mentions-a" href="/user/niente-00" aria-label="Profile: Niente-00">@<bdi>Niente-00</bdi></a> on this subject.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/77983</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/77983</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Tue, 28 Jun 2022 13:10:09 GMT</pubDate></item><item><title><![CDATA[Reply to Cannot sort lines ending with \n or \r only on Tue, 28 Jun 2022 11:52:39 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/terry-r" aria-label="Profile: terry-r">@<bdi>terry-r</bdi></a> said in <a href="/post/77979">Cannot sort lines ending with \n or \r only</a>:</p>
<blockquote>
<p dir="auto">I don’t think it is broken</p>
</blockquote>
<p dir="auto">Opinions vary on this.</p>
<p dir="auto">See <a href="https://github.com/notepad-plus-plus/notepad-plus-plus/issues/7735" rel="nofollow ugc">HERE</a>.</p>
<p dir="auto">The real problem might be, that line-endings that don’t match a file’s setting (per what is shown in the status bar), are allowed to be in a file.  Meaning that if this situation was not allowed to exist, sorting would not have a problem.</p>
<p dir="auto">On the other hand, restricting line-endings to be of one type may be limiting to some users.  I don’t know of a use-case for mixed line-endings, but there probably are some.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/77980</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/77980</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Tue, 28 Jun 2022 11:52:39 GMT</pubDate></item><item><title><![CDATA[Reply to Cannot sort lines ending with \n or \r only on Tue, 28 Jun 2022 08:49:05 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/niente-00" aria-label="Profile: niente-00">@<bdi>niente-00</bdi></a> said in <a href="/post/77978">Cannot sort lines ending with \n or \r only</a>:</p>
<blockquote>
<p dir="auto">Hi, I cannot sort lines terminating with just the “\n” or “\r” characters.<br />
If they end with “\r\n” the sort command works correctly.<br />
Could you please fix this?<br />
Thank you</p>
</blockquote>
<p dir="auto">Firstly we (as in forum members) cannot fix this, we are just users trying to help other users.</p>
<p dir="auto">Secondly I don’t think it is broken. There was a post <a href="https://community.notepad-plus-plus.org/topic/16313/sort-lines-lexicographically-did-not-work">here</a> talking about the same thing. There was a post from <a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a>  that shows it working at the bottom of the first page of that thread.</p>
<p dir="auto">Confirm that you don’t have mixed line endings. You could use the built-in function to change line endings (EOL Conversion under Edit menu), rotating through all three options back to your preferred one. See if that seems to solve your issue.</p>
<p dir="auto">Terry</p>
<p dir="auto">PS I should add that when reporting a bug, here is a good place to start as often members can confirm the issue, or supply how it really works. But to really report a bug to the developer, please read the FAQ section on where that report needs to go, but it isn’t in this forum sorry.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/77979</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/77979</guid><dc:creator><![CDATA[Terry R]]></dc:creator><pubDate>Tue, 28 Jun 2022 08:49:05 GMT</pubDate></item></channel></rss>