<?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[Sort as "aaAAbbBBccCC" or "AAaaBBbbCCcc" but not "AABBCCaabbcc", "aabbccAABBCC", or "aAAaBbbBCcCc"]]></title><description><![CDATA[<p dir="auto">NPP 7.8.9 32-bit, Windows 10</p>
<p dir="auto">Given 12 lines that start with each one of these letters “aCcBAbbAcaCB”, “Edit / Line Operations / Sort Lines Lexicographically Ascending” will produce a sort that looks like “AABBCCaabbcc”.  But what I want is a strictly alphabetical sort i.e. “aaAAbbBBccCC” or “AAaaBBbbCCcc”.</p>
<p dir="auto">I probably should have asked here first if there was an easy way, but instead I put together a Python script which assumes I’ve copied the lines to the clipboard, sends the data to the Windows command line to run its SORT command, then returns the results to the clipboard, so I can paste over the current text.</p>
<p dir="auto">I’m not a Python programmer, so this code is probably not optimal, but did I miss an easier way besides a Python script to do this?</p>
<pre><code>import os
import subprocess
import win32clipboard as cb
import fileinput

fp1 = "C:\\nppsort1.tmp"
fp2 = "C:\\nppsort2.tmp"
try:
    cb.OpenClipboard()
    data=cb.GetClipboardData()

    tempFile = open(fp1, "w")
    tempFile.write(data)
    tempFile.close()

    command = "sort " + fp1 + " /OUTPUT " + fp2
    process = subprocess.Popen(command.split(), stdout=subprocess.PIPE)
    output, error = process.communicate()

    with open(fp2, 'r') as f:
        results = f.read()
    cb.EmptyClipboard()
    cb.SetClipboardData(cb.CF_TEXT, results)

finally:
    cb.CloseClipboard()
    os.remove(fp1)
    os.remove(fp2)
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/topic/19979/sort-as-aaaabbbbcccc-or-aaaabbbbcccc-but-not-aabbccaabbcc-aabbccaabbcc-or-aaaabbbbcccc</link><generator>RSS for Node</generator><lastBuildDate>Sat, 10 Oct 2026 04:50:57 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/19979.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 10 Sep 2020 14:02:20 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Sort as "aaAAbbBBccCC" or "AAaaBBbbCCcc" but not "AABBCCaabbcc", "aabbccAABBCC", or "aAAaBbbBCcCc" on Thu, 10 Sep 2020 15:13:18 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/vtgroupgithub" aria-label="Profile: VTGroupGitHub">@<bdi>VTGroupGitHub</bdi></a> said in <a href="/post/57520">Sort as "aaAAbbBBccCC" or "AAaaBBbbCCcc" but not "AABBCCaabbcc", "aabbccAABBCC", or "aAAaBbbBCcCc"</a>:</p>
<blockquote>
<p dir="auto">as I almost made … my post body “See title.”</p>
</blockquote>
<p dir="auto">Thank you for not.  That might’ve earned you a downvote on your OP from some users here, rather than getting you an answer. :-)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/57521</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57521</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Thu, 10 Sep 2020 15:13:18 GMT</pubDate></item><item><title><![CDATA[Reply to Sort as "aaAAbbBBccCC" or "AAaaBBbbCCcc" but not "AABBCCaabbcc", "aabbccAABBCC", or "aAAaBbbBCcCc" on Thu, 10 Sep 2020 15:11:50 GMT]]></title><description><![CDATA[<p dir="auto">Agreed.  And it’s funny you say that, as I almost made my title “Sort “aCcBAbbAcaCB” as “aaAAbbBBccCC” or “AAaaBBbbCCcc” but not “AABBCCaabbcc”, “aabbccAABBCC”, or “aAAaBbbBCcCc””, and my post body “See title.”.  :)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/57520</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57520</guid><dc:creator><![CDATA[VTGroupGitHub]]></dc:creator><pubDate>Thu, 10 Sep 2020 15:11:50 GMT</pubDate></item><item><title><![CDATA[Reply to Sort as "aaAAbbBBccCC" or "AAaaBBbbCCcc" but not "AABBCCaabbcc", "aabbccAABBCC", or "aAAaBbbBCcCc" on Thu, 10 Sep 2020 15:11:17 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a> said in <a href="/post/57512">Sort as "aaAAbbBBccCC" or "AAaaBBbbCCcc" but not "AABBCCaabbcc", "aabbccAABBCC", or "aAAaBbbBCcCc"</a>:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a> said in <a href="/post/57510">Sort as "aaAAbbBBccCC" or "AAaaBBbbCCcc" but not "AABBCCaabbcc", "aabbccAABBCC", or "aAAaBbbBCcCc"</a>:</p>
<blockquote>
<p dir="auto">I could throw together yet another script to do it quickly, but it is probably better to just cite something that has previously been done.</p>
</blockquote>
<p dir="auto">Well, Peter violated this principle, but I’ve no problem with that! :-)</p>
</blockquote>
<p dir="auto">Note that my googling for how to sort case-insensitive in python, coming up with a one liner myself, and then cleaning it up into a readable script took less time than trying to find a bit of code in this forum.   I really like and appreciate this forum, but searching it is … not always helpful or efficient. :-)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/57519</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57519</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Thu, 10 Sep 2020 15:11:17 GMT</pubDate></item><item><title><![CDATA[Reply to Sort as "aaAAbbBBccCC" or "AAaaBBbbCCcc" but not "AABBCCaabbcc", "aabbccAABBCC", or "aAAaBbbBCcCc" on Thu, 10 Sep 2020 15:08:57 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a> said in <a href="/post/57516">Sort as "aaAAbbBBccCC" or "AAaaBBbbCCcc" but not "AABBCCaabbcc", "aabbccAABBCC", or "aAAaBbbBCcCc"</a>:</p>
<blockquote>
<p dir="auto">Sorry, I also didn’t notice what was really wanted here.</p>
</blockquote>
<p dir="auto">Since the only place he mentioned that he didn’t want that particular <code>aAAaBbbBCcCc</code> answer was in the “not” list in the title, I think we should be forgiven for not noticing. :-)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/57518</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57518</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Thu, 10 Sep 2020 15:08:57 GMT</pubDate></item><item><title><![CDATA[Reply to Sort as "aaAAbbBBccCC" or "AAaaBBbbCCcc" but not "AABBCCaabbcc", "aabbccAABBCC", or "aAAaBbbBCcCc" on Thu, 10 Sep 2020 15:08:46 GMT]]></title><description><![CDATA[<p dir="auto">Your solution sounds like it should work!  I hadn’t considered “+s”, so will test as soon as I can and close this issue.</p>
<p dir="auto">Thanks to both of you.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/57517</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57517</guid><dc:creator><![CDATA[VTGroupGitHub]]></dc:creator><pubDate>Thu, 10 Sep 2020 15:08:46 GMT</pubDate></item><item><title><![CDATA[Reply to Sort as "aaAAbbBBccCC" or "AAaaBBbbCCcc" but not "AABBCCaabbcc", "aabbccAABBCC", or "aAAaBbbBCcCc" on Thu, 10 Sep 2020 15:06:58 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/vtgroupgithub" aria-label="Profile: VTGroupGitHub">@<bdi>VTGroupGitHub</bdi></a></p>
<p dir="auto">Sorry, I also didn’t notice what was really wanted here. :-(</p>
]]></description><link>https://community.notepad-plus-plus.org/post/57516</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57516</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Thu, 10 Sep 2020 15:06:58 GMT</pubDate></item><item><title><![CDATA[Reply to Sort as "aaAAbbBBccCC" or "AAaaBBbbCCcc" but not "AABBCCaabbcc", "aabbccAABBCC", or "aAAaBbbBCcCc" on Thu, 10 Sep 2020 15:05:42 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/vtgroupgithub" aria-label="Profile: VTGroupGitHub">@<bdi>VTGroupGitHub</bdi></a> ,</p>
<p dir="auto">Sorry, didn’t notice that you wanted a combo of insensitive + sensitive.</p>
<p dir="auto">Change the lambda expression.  I think doing s.lower()+s will give you want you want.  when it is comparing the <code>a</code> line to the <code>A</code> line, the sort key will be <code>aa</code> vs <code>aA</code>, so it will put the upper-case first:</p>
<pre><code>editor.setText("\r\n".join(sorted(editor.getText().splitlines(), key=lambda s: s.lower()+s)))
</code></pre>
<p dir="auto">=&gt; <code>AAaaBBbbCCcc</code></p>
]]></description><link>https://community.notepad-plus-plus.org/post/57515</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57515</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Thu, 10 Sep 2020 15:05:42 GMT</pubDate></item><item><title><![CDATA[Reply to Sort as "aaAAbbBBccCC" or "AAaaBBbbCCcc" but not "AABBCCaabbcc", "aabbccAABBCC", or "aAAaBbbBCcCc" on Thu, 10 Sep 2020 14:59:30 GMT]]></title><description><![CDATA[<p dir="auto">Thanks, but unless I’m not seeing something different between your code and mine, I think this is what I tried first.  Won’t it give you the “aAAaBbbBCcCc” results?  That is, it sorts the aA’s in the order they’re in in the file, and not alphabetical AND case order.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/57514</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57514</guid><dc:creator><![CDATA[VTGroupGitHub]]></dc:creator><pubDate>Thu, 10 Sep 2020 14:59:30 GMT</pubDate></item><item><title><![CDATA[Reply to Sort as "aaAAbbBBccCC" or "AAaaBBbbCCcc" but not "AABBCCaabbcc", "aabbccAABBCC", or "aAAaBbbBCcCc" on Thu, 10 Sep 2020 14:58:16 GMT]]></title><description><![CDATA[<p dir="auto">It took a bit to find it for some reason, but here’s basically the same script as Peter’s more recent one:</p>
<p dir="auto"><a href="https://community.notepad-plus-plus.org/post/55681">https://community.notepad-plus-plus.org/post/55681</a></p>
]]></description><link>https://community.notepad-plus-plus.org/post/57513</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57513</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Thu, 10 Sep 2020 14:58:16 GMT</pubDate></item><item><title><![CDATA[Reply to Sort as "aaAAbbBBccCC" or "AAaaBBbbCCcc" but not "AABBCCaabbcc", "aabbccAABBCC", or "aAAaBbbBCcCc" on Thu, 10 Sep 2020 14:52:52 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a> said in <a href="/post/57510">Sort as "aaAAbbBBccCC" or "AAaaBBbbCCcc" but not "AABBCCaabbcc", "aabbccAABBCC", or "aAAaBbbBCcCc"</a>:</p>
<blockquote>
<p dir="auto">I could throw together yet another script to do it quickly, but it is probably better to just cite something that has previously been done.</p>
</blockquote>
<p dir="auto">Well, Peter violated this principle, but I’ve no problem with that! :-)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/57512</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57512</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Thu, 10 Sep 2020 14:52:52 GMT</pubDate></item><item><title><![CDATA[Reply to Sort as "aaAAbbBBccCC" or "AAaaBBbbCCcc" but not "AABBCCaabbcc", "aabbccAABBCC", or "aAAaBbbBCcCc" on Thu, 10 Sep 2020 14:50:33 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/vtgroupgithub" aria-label="Profile: VTGroupGitHub">@<bdi>VTGroupGitHub</bdi></a> ,</p>
<pre><code>from Npp import *
editor.setText("\r\n".join(sorted(editor.getText().splitlines(), key=lambda s: s.lower())))
</code></pre>
<p dir="auto">Okay, so that’s the compressed way.  To make it more intelligible:</p>
<pre><code>from Npp import editor                                  # make sure you know the `editor` object

editor.beginUndoAction()                                # use the begin/end undo action to make a single ^Z undo the whole sorting action

lines = editor.getText().splitlines()                   # get a list of the lines in the active editor window

sorted_lines = sorted(lines, key=lambda s: s.lower())   # use the lowercase version of the text as the key for sorting, but the data itself doesn't change case

joined = "\r\n".join(sorted_lines)                      # join the lines together

editor.setText(joined)                                  # change the text in the  active editor window

editor.endUndoAction()                                  # use the begin/end undo action to make a single ^Z undo the whole sorting action
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/57511</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57511</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Thu, 10 Sep 2020 14:50:33 GMT</pubDate></item><item><title><![CDATA[Reply to Sort as "aaAAbbBBccCC" or "AAaaBBbbCCcc" but not "AABBCCaabbcc", "aabbccAABBCC", or "aAAaBbbBCcCc" on Thu, 10 Sep 2020 14:45:51 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/vtgroupgithub" aria-label="Profile: VTGroupGitHub">@<bdi>VTGroupGitHub</bdi></a> said in <a href="/post/57508">Sort as "aaAAbbBBccCC" or "AAaaBBbbCCcc" but not "AABBCCaabbcc", "aabbccAABBCC", or "aAAaBbbBCcCc"</a>:</p>
<blockquote>
<p dir="auto">And this script is actually running via the PythonScript plugin</p>
</blockquote>
<p dir="auto">Ohhh…  That’s even worse then.  :-)<br />
I thought you were doing some sort of <em>Run</em> menu entry, shelling out to an independent Python.</p>
<p dir="auto">I’m still digging through previous posts on this topic.<br />
I could throw together yet another script to do it quickly, but it is probably better to just cite something that has previously been done.<br />
Check back…</p>
]]></description><link>https://community.notepad-plus-plus.org/post/57510</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57510</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Thu, 10 Sep 2020 14:45:51 GMT</pubDate></item><item><title><![CDATA[Reply to Sort as "aaAAbbBBccCC" or "AAaaBBbbCCcc" but not "AABBCCaabbcc", "aabbccAABBCC", or "aAAaBbbBCcCc" on Thu, 10 Sep 2020 14:36:32 GMT]]></title><description><![CDATA[<p dir="auto">“Roundabout” is a good word.  :)  That’s actually why I asked, because even though it works, I figured there had to be an easier way.  And this script is actually running via the PythonScript plugin, and I’ve got a button on my toolbar now to run it.</p>
<p dir="auto">Any other ideas you have would be much appreciated.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/57508</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57508</guid><dc:creator><![CDATA[VTGroupGitHub]]></dc:creator><pubDate>Thu, 10 Sep 2020 14:36:32 GMT</pubDate></item><item><title><![CDATA[Reply to Sort as "aaAAbbBBccCC" or "AAaaBBbbCCcc" but not "AABBCCaabbcc", "aabbccAABBCC", or "aAAaBbbBCcCc" on Thu, 10 Sep 2020 14:29:58 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/vtgroupgithub" aria-label="Profile: VTGroupGitHub">@<bdi>VTGroupGitHub</bdi></a> said in <a href="/post/57504">Sort as "aaAAbbBBccCC" or "AAaaBBbbCCcc" but not "AABBCCaabbcc", "aabbccAABBCC", or "aAAaBbbBCcCc"</a>:</p>
<blockquote>
<p dir="auto">but did I miss an easier way besides a Python script to do this?</p>
</blockquote>
<p dir="auto">Well, maybe.</p>
<p dir="auto">First, Notepad++ does not natively support a case-insensitive sort, which I <em>think</em> is what you are seeking?</p>
<p dir="auto">There is talk about it; see <a href="https://github.com/notepad-plus-plus/notepad-plus-plus/issues/4479" rel="nofollow ugc">HERE</a>, but an insensitive sort is not a straightforward thing. You probably <em>think</em> that it is, but if you bring Unicode and locales into the conversation, you rapidly see that it is not so clear cut.</p>
<p dir="auto">Second, your Python approach is a bit, well, roundabout.<br />
It’s great that it works, but…there are simpler and better ways.</p>
<p dir="auto">Notepad++ has a great plugin called <em>Pythonscript</em>, which gives you nice Python control of the editor and its data, right inside Notepad++.  I’ll see what I can find for this, and I’ll post again…</p>
]]></description><link>https://community.notepad-plus-plus.org/post/57506</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/57506</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Thu, 10 Sep 2020 14:29:58 GMT</pubDate></item></channel></rss>