<?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 a list of filenames alphabetically but grouped by their extension]]></title><description><![CDATA[<p dir="auto">I have a text file which goes like this:</p>
<p dir="auto">apple.c<br />
orange.hpp<br />
plum.h<br />
mango.c<br />
banana.cpp<br />
grapes.hpp</p>
<p dir="auto">I want the above text sorted alphabetically but grouped based on their extensions: i.e,</p>
<p dir="auto">apple.c<br />
mango.c<br />
banana.cpp<br />
plum.h<br />
grapes.hpp<br />
orange.hpp</p>
<p dir="auto">How can I do this in Notepad++?</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/12987/sort-a-list-of-filenames-alphabetically-but-grouped-by-their-extension</link><generator>RSS for Node</generator><lastBuildDate>Tue, 06 Oct 2026 02:37:05 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/12987.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 28 Dec 2016 12:48:16 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Sort a list of filenames alphabetically but grouped by their extension on Wed, 28 Dec 2016 18:30:59 GMT]]></title><description><![CDATA[<p dir="auto">Hi <strong>Anu Anand Premji</strong> and <strong>All</strong>,</p>
<p dir="auto">Well, I’m back home and here are some <strong>explanations</strong> on the <strong>two</strong> S/R :</p>
<ul>
<li>
<p dir="auto">The two <strong>search</strong> regex begin with the modifier <strong><code>(?-s)</code></strong> ( <strong>No PCRE_DOTALL</strong> ) that ensures that the regex engine will consider the <strong>dot</strong> special character <strong><code>.</code></strong> will match only a single <strong>standard</strong> character and <strong>not</strong> an <strong>EOL</strong> character</p>
</li>
<li>
<p dir="auto">Then the part, <strong><code>^.+\.</code></strong> matches, from the <strong>beginning</strong> of the current line <strong><code>^</code></strong>,  a <strong>maximum</strong>, NON empty, of characters, till a <strong>literal</strong> dot character ( which must be <strong>escaped</strong> by an <strong>antislash</strong> character <strong><code>\</code></strong> in order to be considered as <strong>literal</strong> ) So, if the filename would be, for instance, “abc.def.ghi.cpp”, this range would be the string <strong>abc.def.ghi</strong></p>
</li>
<li>
<p dir="auto">The remainder of the <strong>search</strong> regex <strong><code>(.+)</code></strong>  catches the <strong>remainder</strong> of the <strong>standard</strong> characters of the current line ( The <strong>extension</strong> part ) which is stored as <strong>group 1</strong>, due to the couple of <strong>parentheses</strong></p>
</li>
<li>
<p dir="auto">In <strong>replacement</strong>, the regex <strong><code>\1\t\t$0</code></strong> rewrites the <strong>group 1</strong> ( The <strong>extension</strong> part ), then two <strong>tabulation</strong> characters and, finally, the <strong>searched</strong> string, that is to say the <strong>name</strong> of each file, with its <strong>extension</strong> ( part <strong><code>$0</code></strong>  )</p>
</li>
<li>
<p dir="auto">I preferred to use the <strong>tabulation</strong> character, instead of some <strong>spaces</strong>, because, with the <strong>tabulation</strong> character, the complete filenames look all <strong>aligned</strong> :-)</p>
</li>
<li>
<p dir="auto">In the <strong>second</strong> S/R the part <strong><code>^.+</code></strong> selects, from the <strong>beginning</strong> of each line <strong><code>^</code></strong>,  the range <strong>maximum</strong>, NON empty, of <strong>standard</strong> characters, till a <strong>non</strong> empty range of <strong>tabulation</strong> characters <strong><code>\t+</code></strong></p>
</li>
<li>
<p dir="auto">As the <strong>replacement</strong> field is, this time, <strong>empty</strong>, <strong>all</strong> these characters, included <strong>tabulations</strong> , are, simply, <strong>deleted</strong> !</p>
</li>
</ul>
<p dir="auto">Cheers,</p>
<p dir="auto">guuy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/20342</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/20342</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Wed, 28 Dec 2016 18:30:59 GMT</pubDate></item><item><title><![CDATA[Reply to Sort a list of filenames alphabetically but grouped by their extension on Wed, 28 Dec 2016 15:29:45 GMT]]></title><description><![CDATA[<p dir="auto">Wow!!! That worked perfectly!! Thank you!!<br />
Saved me a lot of work!!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/20338</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/20338</guid><dc:creator><![CDATA[Anu Anand Premji]]></dc:creator><pubDate>Wed, 28 Dec 2016 15:29:45 GMT</pubDate></item><item><title><![CDATA[Reply to Sort a list of filenames alphabetically but grouped by their extension on Wed, 28 Dec 2016 15:10:58 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <strong>Anu Anand Premji</strong>,</p>
<p dir="auto">Very <strong>easily</strong>, indeed ! you just need <strong>two</strong> S/R, in <strong>regex</strong> mode and a classical <strong>sort</strong> :-))</p>
<p dir="auto">So, from your <strong>original</strong> text, below :</p>
<pre><code>apple.c
orange.hpp
plum.h
mango.c
banana.cpp
grapes.hpp
</code></pre>
<ul>
<li>
<p dir="auto">First, move <strong>back</strong> to the <strong>very beginning</strong> of your file, containing a list of <strong>filenames</strong> ( <strong>Ctrl + Home</strong> )</p>
</li>
<li>
<p dir="auto">Open the <strong>Replace</strong> dialog ( <strong>Ctrl + H</strong> )</p>
</li>
<li>
<p dir="auto">Select the <strong>Regular expression</strong> search mode</p>
</li>
<li>
<p dir="auto">Fill up the <strong>two</strong> fields <strong>Find what:</strong> and <strong>Replace with:</strong>, with the values, below :</p>
</li>
</ul>
<p dir="auto">SEARCH <strong><code>(?-s)^.+\.(.+)</code></strong></p>
<p dir="auto">REPLACE <strong><code>\1\t\t$0</code></strong></p>
<ul>
<li>Click on the <strong>Replace all</strong> button</li>
</ul>
<p dir="auto">=&gt; You should obtain the <strong>changed</strong> text, below :</p>
<pre><code>c		apple.c
hpp		orange.hpp
h		plum.h
c		mango.c
cpp		banana.cpp
hpp		grapes.hpp
</code></pre>
<ul>
<li>Now, perform a classical <strong>sort</strong> with the menu option <strong>Edit &gt; Line operations &gt; Sort Lines Lexicographically Ascending</strong></li>
</ul>
<p dir="auto">=&gt; We get the <strong>sorted</strong> text, below :</p>
<pre><code>c		apple.c
c		mango.c
cpp		banana.cpp
h		plum.h
hpp		grapes.hpp
hpp		orange.hpp
</code></pre>
<ul>
<li>Again, open the <strong>Replace</strong> dialog and type the <strong>regex</strong> expressions, below :</li>
</ul>
<p dir="auto">SEARCH <strong><code>(?-s)^.+\t+</code></strong></p>
<p dir="auto">REPLACE <strong><code>Leave the field EMPTY</code></strong></p>
<p dir="auto">Yeah ! Here is our <strong>final</strong> text, <strong>sorted</strong> as expected :-))</p>
<pre><code>apple.c
mango.c
banana.cpp
plum.h
grapes.hpp
orange.hpp
</code></pre>
<p dir="auto">I’ve got to be out for a while ! But, when I’m  home, I’ll add some <strong>explanations</strong> to my regexes, just in case that you’re not acquainted with <strong>regular expressions</strong> !</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/20337</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/20337</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Wed, 28 Dec 2016 15:10:58 GMT</pubDate></item></channel></rss>