<?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[File sorting]]></title><description><![CDATA[<p dir="auto">I’m new here so please be gentle!!!<br />
Is it possible to sort a file by line length??<br />
Thats all!<br />
Thanks<br />
Dave</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/17983/file-sorting</link><generator>RSS for Node</generator><lastBuildDate>Fri, 17 Apr 2026 18:10:08 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/17983.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 23 Jul 2019 07:38:38 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to File sorting on Mon, 03 Jun 2024 14:59:58 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/30939">@Mahmoud-Madkour</a><br />
To open a tree view for a file in <code>REGEX</code> mode, just use the <code>Regex search to JSON</code> command from the <code>JsonTools</code> plugin menu.<br />
Once the tree view is open, you can paste the query into the text box at the top right corner of the tree view, and click the <code>Submit query</code> button next to the text box.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/95147</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/95147</guid><dc:creator><![CDATA[Mark Olson]]></dc:creator><pubDate>Mon, 03 Jun 2024 14:59:58 GMT</pubDate></item><item><title><![CDATA[Reply to File sorting on Mon, 03 Jun 2024 07:55:41 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/26710">@Mark-Olson</a> , your proposed solution seems to be so easy but  can you please elaborate more,<br />
1- how to open the file in tree view<br />
2- how to go to REGEX mode to enter the query</p>
<p dir="auto">many thanks</p>
]]></description><link>https://community.notepad-plus-plus.org/post/95143</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/95143</guid><dc:creator><![CDATA[Mahmoud Madkour]]></dc:creator><pubDate>Mon, 03 Jun 2024 07:55:41 GMT</pubDate></item><item><title><![CDATA[Reply to File sorting on Thu, 14 Dec 2023 21:30:39 GMT]]></title><description><![CDATA[<p dir="auto">In case anyone comes across this topic looking for a way to sort lines by length, <a href="https://github.com/Coises/ColumnsPlusPlus/releases/tag/v1.0.1" rel="nofollow ugc">Columns++ release 1.0.1</a> can do this.</p>
<p dir="auto">Select <strong>Sort…</strong> from the Columns++ menu and let it enclose the entire document in a rectangular selection (or make your own selection first).</p>
<p dir="auto">Use <strong>Whole lines</strong>, <strong>Ascending</strong> or <strong>Descending</strong> as desired, and <strong>Width</strong>. You can then sort on <strong>Entire column</strong>, unless you wish to use one of the other options.</p>
<p dir="auto">The sort is based on the on-screen width of text in the current font. Columns++ is meant to deal with data in columns using tabs, including elastic tabstops and proportionally-spaced fonts; I found that using the width, rather than a count of characters, was the most consistent way to deal with all the variations in a way that makes intuitive sense for users. For files using monospaced fonts and no tabs, the results are the same as counting characters.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/91241</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/91241</guid><dc:creator><![CDATA[Coises]]></dc:creator><pubDate>Thu, 14 Dec 2023 21:30:39 GMT</pubDate></item><item><title><![CDATA[Reply to File sorting on Wed, 13 Dec 2023 23:18:54 GMT]]></title><description><![CDATA[<p dir="auto"><a href="https://github.com/molsonkiko/JsonToolsNppPlugin/releases/tag/v6.0.0" rel="nofollow ugc">JsonTools v6.0 or higher</a>, open treeview for document, go to <code>REGEX mode</code>, enter query  <code>@ = s_join(`\r\n`, sort_by(s_split(@, `\r\n`), s_len(@)))</code><br />
Hopefully the syntax is reasonably easy to understand- split the file by <code>\r\n</code>, sort the list of lines by string length, then set the document’s text (<code>@</code>) to the result of string-joining the list back together with <code>\r\n</code>.</p>
<p dir="auto">This converts</p>
<pre><code>abcdefg
ab
abcdefgh
a
abcdefghi
abcde
abcd
abc
</code></pre>
<p dir="auto">into</p>
<pre><code>a
ab
abc
abcd
abcde
abcdefg
abcdefgh
abcdefghi
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/91215</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/91215</guid><dc:creator><![CDATA[Mark Olson]]></dc:creator><pubDate>Wed, 13 Dec 2023 23:18:54 GMT</pubDate></item><item><title><![CDATA[Reply to File sorting on Wed, 13 Dec 2023 17:47:15 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/28326">@Thomas-Knoefel</a></p>
<p dir="auto">I received a <a href="https://github.com/Coises/ColumnsPlusPlus/issues/15" rel="nofollow ugc">feature request</a> related to this post. It doesn’t quite feel like a good fit for Columns++ to me, but I think your <a href="https://github.com/daddel80/notepadpp-multireplace" rel="nofollow ugc">MultiReplace</a> plugin can assist in making this possible in a reasonable number of steps.</p>
<p dir="auto">I believe multi-replace can be set up to find <strong><code>^.*$</code></strong> and replace with <strong><code>set(string.len(MATCH).." "..MATCH)</code></strong>.</p>
<p dir="auto">Then <strong>Edit</strong> | <strong>Line operations</strong> | <strong>Sort Lines As Integers Ascending</strong> will sort the lines in order by length, and then <strong><code>^\d+\x20</code></strong> replaced with nothing would remove the lengths.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/91204</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/91204</guid><dc:creator><![CDATA[Coises]]></dc:creator><pubDate>Wed, 13 Dec 2023 17:47:15 GMT</pubDate></item><item><title><![CDATA[Reply to File sorting on Wed, 25 Oct 2023 02:20:17 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <strong>All</strong>,</p>
<p dir="auto">Thanks to, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/5329">@mkupper</a>, which <strong>recently</strong> posted a comment and exactly, <strong>three</strong> years later, I going to <strong>simplify</strong> the way to get a <strong>sort</strong> by <strong>length</strong> of lines and, secondly, by line <strong>contents</strong>, too !</p>
<p dir="auto">Like in my <strong>previous</strong> post, I will use this list of <strong>rivers</strong>, below :</p>
<p dir="auto"><a href="https://en.wikipedia.org/wiki/List_of_rivers_by_length" rel="nofollow ugc">https://en.wikipedia.org/wiki/List_of_rivers_by_length</a></p>
<p dir="auto">After suppression of some <strong>doublons</strong>, we get an <em>INPUT</em> text of <strong><code>238</code></strong> river’s names :</p>
<pre><code class="language-diff">Nile
White Nile
Kagera
Nyabarongo
Mwogo
Rukarara
Amazon
Ucayali
Tambo
Ene
Mantaro
Yangtze
Mississippi
Missouri
Jefferson
Beaverhead
Red Rock
Hell Roaring
Yenisei
Angara
Selenge
Ider
Yellow River
Ob
Irtysh
Río de la Plata
Paraná
Congo
Chambeshi
Amur
Argun
Kherlen
Lena
Mekong
Mackenzie
Slave
Peace
Finlay
Niger
Brahmaputra
Tsangpo
Murray
Darling
Culgoa
Balonne
Condamine
Tocantins
Araguaia
Volga
Indus
Sênggê Zangbo
Shatt al-Arab
Euphrates
Murat
Madeira
Mamoré
Caine
Rocha
Purús
Yukon
São Francisco
Syr Darya
Naryn
Salween
Saint Lawrence
Niagara
Detroit
Saint Clair
Saint Marys
Saint Louis
North
Nizhnyaya Tunguska
Danube
Breg
Zambezi
Vilyuy
Ganges
Hooghly
Padma
Amu Darya
Panj
Japurá
Nelson
Saskatchewan
Paraguay
Kolyma
Pilcomayo
Biya
Katun
Ishim
Juruá
Ural
Arkansas
Colorado
Olenyok
Dnieper
Aldan
Ubangi
Uele
Negro
Columbia
Zhujiang
Red
Ayeyarwady
Kasai
Ohio
Allegheny
Orinoco
Tarim
Xingu
Orange
Salado
Vitim
Tigris
Songhua
Tapajós
Don
Podkamennaya Tunguska
Pechora
Kama
Limpopo
Chulym
Guaporé
Indigirka
Snake
Senegal
Uruguay
Blue Nile
Churchill
Khatanga
Okavango
Volta
Beni
Platte
Tobol
Alazeya
Jubba
Shebelle
Içá
Magdalena
Han
Kura
Oka
Guaviare
Pecos
Murrumbidgee
Godavari
Río Grande
Belaya
Cooper
Barcoo
Marañón
Dniester
Benue
Ili
Warburton
Georgina
Sutlej
Yamuna
Vyatka
Fraser
Brazos
Liao
Lachlan
Yalong
Iguaçu
Olyokma
Northern Dvina
Sukhona
Krishna
Iriri
Narmada
Lomami
Ottawa
Lerma
Grande de Santiago
Elbe
Vltava
Zeya
Juruena
Rhine
Athabasca
Canadian
North Saskatchewan
Vistula
Bug
Vaal
Shire
Ogooué
Nen
Kızılırmak
Markha
Green
Milk
Chindwin
Sankuru
Wu
James
Kapuas
Desna
Helmand
Madre de Dios
Tietê
Vychegda
Sepik
Cimarron
Anadyr
Paraíba do Sul
Jialing
Liard
Cumberland
White
Huallaga
Kwango
Draa
Gambia
Tyung
Chenab
Yellowstone
Ghaghara
Huai
Aras
Chu
Seversky Donets
Bermejo
Fly
Kuskokwim
Tennessee
Oder
Warta
Aruwimi
Daugava
Gila
Loire
Essequibo
Khoper
Tagus
Flinders
</code></pre>
<ul>
<li>
<p dir="auto">At end of the <strong>first</strong> line, we add some <strong><code>space</code></strong> chars till <strong>column</strong> <strong><code>100</code></strong></p>
</li>
<li>
<p dir="auto">Then, with a <strong>zero-length</strong> selection, at column <strong><code>100</code></strong>, we insert a <strong>exclamation mark</strong> ( <strong><code>!</code></strong> ) at <strong>end</strong> of  <strong>all</strong> lines of the list :</p>
</li>
</ul>
<p dir="auto">=&gt; We get this <strong>temporary</strong> text ( I just listed the <strong>first</strong> lines and the <strong>last</strong> lines ) :</p>
<pre><code class="language-diff">Nile                                                                                               !
White Nile                                                                                         !
Kagera                                                                                             !
Nyabarongo                                                                                         !
Mwogo                                                                                              !
Rukarara                                                                                           !
Amazon                                                                                             !
Ucayali                                                                                            !
Tambo                                                                                              !
Ene                                                                                                !
Mantaro                                                                                            !
Yangtze                                                                                            !
Mississippi                                                                                        !
Missouri                                                                                           !
......                                                                                             !
......                                                                                             !
......                                                                                             !
......                                                                                             !
Seversky Donets                                                                                    !
Bermejo                                                                                            !
Fly                                                                                                !
Kuskokwim                                                                                          !
Tennessee                                                                                          !
Oder                                                                                               !
Warta                                                                                              !
Aruwimi                                                                                            !
Daugava                                                                                            !
Gila                                                                                               !
Loire                                                                                              !
Essequibo                                                                                          !
Khoper                                                                                             !
Tagus                                                                                              !
Flinders                                                                                           !

</code></pre>
<ul>
<li>
<p dir="auto">Now, we perform this <strong>regex</strong> S/R :</p>
<ul>
<li>
<p dir="auto">SEARCH <strong><code>^([\w -]+?)(\x20+)(?=!)</code></strong></p>
</li>
<li>
<p dir="auto">REPLACE <strong><code>\2\1</code></strong></p>
</li>
</ul>
</li>
</ul>
<p dir="auto">=&gt; Again, we get this <strong>temporary</strong> text ( I just listed the <strong>first</strong> lines and the <strong>last</strong> lines ) :</p>
<pre><code class="language-diff">                                                                                               Nile!
                                                                                         White Nile!
                                                                                             Kagera!
                                                                                         Nyabarongo!
                                                                                              Mwogo!
                                                                                           Rukarara!
                                                                                             Amazon!
                                                                                            Ucayali!
                                                                                              Tambo!
                                                                                                Ene!
                                                                                            Mantaro!
                                                                                            Yangtze!
                                                                                        Mississippi!
                                                                                           Missouri!
                                                                                             ......!
                                                                                             ......!
                                                                                             ......!
                                                                                             ......!
                                                                                    Seversky Donets!
                                                                                            Bermejo!
                                                                                                Fly!
                                                                                          Kuskokwim!
                                                                                          Tennessee!
                                                                                               Oder!
                                                                                              Warta!
                                                                                            Aruwimi!
                                                                                            Daugava!
                                                                                               Gila!
                                                                                              Loire!
                                                                                          Essequibo!
                                                                                             Khoper!
                                                                                              Tagus!
                                                                                           Flinders!
</code></pre>
<ul>
<li>Then, we run the <strong><code>Edit &gt; Line Operations &gt; Sort Lines Lexicographically Ascending</code></strong> option</li>
</ul>
<p dir="auto">==&gt; Here is our <strong>sorted</strong> text ( I just listed the <strong>first</strong> lines and the <strong>last</strong> lines ) :</p>
<pre><code class="language-diff">                                                                                                 Ob!
                                                                                                 Wu!
                                                                                                Bug!
                                                                                                Chu!
                                                                                                Don!
                                                                                                Ene!
                                                                                                Fly!
                                                                                                Han!
                                                                                                Ili!
                                                                                                Içá!
                                                                                                Nen!
                                                                                                Oka!
                                                                                                Red!
                                                                                               Amur!
                                                                                               Aras!
                                                                                             ......!
                                                                                             ......!
                                                                                             ......!
                                                                                             ......!
                                                                                       Saskatchewan!
                                                                                       Yellow River!
                                                                                      Madre de Dios!
                                                                                      Shatt al-Arab!
                                                                                      São Francisco!
                                                                                      Sênggê Zangbo!
                                                                                     Northern Dvina!
                                                                                     Paraíba do Sul!
                                                                                     Saint Lawrence!
                                                                                    Río de la Plata!
                                                                                    Seversky Donets!
                                                                                 Grande de Santiago!
                                                                                 Nizhnyaya Tunguska!
                                                                                 North Saskatchewan!
                                                                              Podkamennaya Tunguska!
</code></pre>
<ul>
<li>
<p dir="auto">Finally, let’s run this last <strong>regex</strong> S/R</p>
<ul>
<li>
<p dir="auto">SEARCH  <strong><code>^\x20+|!$</code></strong></p>
</li>
<li>
<p dir="auto">REPLACE <strong><code>Leave EMPTY</code></strong></p>
</li>
</ul>
</li>
</ul>
<p dir="auto">=&gt; It remains our <strong>expected</strong> <em>OUTPUT</em> text, <strong>sorted</strong>  by <strong><code>line length</code></strong> :</p>
<pre><code class="language-diff">Ob
Wu
Bug
Chu
Don
Ene
Fly
Han
Ili
Içá
Nen
Oka
Red
Amur
Aras
Beni
Biya
Breg
Draa
Elbe
Gila
Huai
Ider
Kama
Kura
Lena
Liao
Milk
Nile
Oder
Ohio
Panj
Uele
Ural
Vaal
Zeya
Aldan
Argun
Benue
Caine
Congo
Desna
Green
Indus
Iriri
Ishim
James
Jubba
Juruá
Kasai
Katun
Lerma
Liard
Loire
Murat
Mwogo
Naryn
Negro
Niger
North
Padma
Peace
Pecos
Purús
Rhine
Rocha
Sepik
Shire
Slave
Snake
Tagus
Tambo
Tarim
Tietê
Tobol
Tyung
Vitim
Volga
Volta
Warta
White
Xingu
Yukon
Amazon
Anadyr
Angara
Barcoo
Belaya
Brazos
Chenab
Chulym
Cooper
Culgoa
Danube
Finlay
Fraser
Gambia
Ganges
Iguaçu
Irtysh
Japurá
Kagera
Kapuas
Khoper
Kolyma
Kwango
Lomami
Mamoré
Markha
Mekong
Murray
Nelson
Ogooué
Orange
Ottawa
Paraná
Platte
Salado
Sutlej
Tigris
Ubangi
Vilyuy
Vltava
Vyatka
Yalong
Yamuna
Alazeya
Aruwimi
Balonne
Bermejo
Darling
Daugava
Detroit
Dnieper
Guaporé
Helmand
Hooghly
Jialing
Juruena
Kherlen
Krishna
Lachlan
Limpopo
Madeira
Mantaro
Marañón
Narmada
Niagara
Olenyok
Olyokma
Orinoco
Pechora
Salween
Sankuru
Selenge
Senegal
Songhua
Sukhona
Tapajós
Tsangpo
Ucayali
Uruguay
Vistula
Yangtze
Yenisei
Zambezi
Araguaia
Arkansas
Canadian
Chindwin
Cimarron
Colorado
Columbia
Dniester
Flinders
Georgina
Ghaghara
Godavari
Guaviare
Huallaga
Khatanga
Missouri
Okavango
Paraguay
Red Rock
Rukarara
Shebelle
Vychegda
Zhujiang
Allegheny
Amu Darya
Athabasca
Blue Nile
Chambeshi
Churchill
Condamine
Essequibo
Euphrates
Indigirka
Jefferson
Kuskokwim
Mackenzie
Magdalena
Pilcomayo
Syr Darya
Tennessee
Tocantins
Warburton
Ayeyarwady
Beaverhead
Cumberland
Kızılırmak
Nyabarongo
Río Grande
White Nile
Brahmaputra
Mississippi
Saint Clair
Saint Louis
Saint Marys
Yellowstone
Hell Roaring
Murrumbidgee
Saskatchewan
Yellow River
Madre de Dios
Shatt al-Arab
São Francisco
Sênggê Zangbo
Northern Dvina
Paraíba do Sul
Saint Lawrence
Río de la Plata
Seversky Donets
Grande de Santiago
Nizhnyaya Tunguska
North Saskatchewan
Podkamennaya Tunguska
</code></pre>
<p dir="auto">That’s all ! <strong>Neat</strong>, isn’t it ?</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/90069</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/90069</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Wed, 25 Oct 2023 02:20:17 GMT</pubDate></item><item><title><![CDATA[Reply to File sorting on Tue, 24 Oct 2023 13:54:57 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a> You essentially did “programming” with a human computer doing the evaluations and flow control. :-)</p>
<p dir="auto">That reminds me of the stories about the first computers, which was a human job title, for those that computed but also had to do flow control! When ways were figured out in how to do parts of the job, first via mechanical means, and then electronic, the resulting machines came to be known as computers.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/90058</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/90058</guid><dc:creator><![CDATA[mkupper]]></dc:creator><pubDate>Tue, 24 Oct 2023 13:54:57 GMT</pubDate></item><item><title><![CDATA[Reply to File sorting on Mon, 23 Oct 2023 17:46:10 GMT]]></title><description><![CDATA[<p dir="auto">@ Dave-Pruce said :</p>
<blockquote>
<p dir="auto">Is it possible to sort a file by line length??</p>
</blockquote>
<p dir="auto">Yes, not natively, but there is a Notepad++ plugin for it: <strong>Linesort v1.1</strong> (but only for 32bit Notepad++) :</p>
<pre><code>https://webarchive.org/web/20200207125518/http://www.scout-soft.com/linesort/
</code></pre>
<p dir="auto"><img src="/assets/uploads/files/1698079837864-linesort.png" alt="linesort.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.notepad-plus-plus.org/post/90037</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/90037</guid><dc:creator><![CDATA[freezer2022]]></dc:creator><pubDate>Mon, 23 Oct 2023 17:46:10 GMT</pubDate></item><item><title><![CDATA[Reply to File sorting on Wed, 24 Jul 2019 18:21:36 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/15933">@dave-pruce</a>, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@alan-kilborn</a>,</p>
<p dir="auto">Yes, your <strong>new</strong> attempt, <strong>Alan</strong>, is the solution, when working with <strong><code>UTF8</code></strong> encoded files, which may content <strong>multi-bytes</strong> encoded chars !</p>
<p dir="auto">As for me, I was thinking about the <strong>opposite</strong> solution : to convert <strong><code>UTf8</code></strong>-files to <strong><code>ANSI</code></strong>. However, when using this solution, some characters may result in <strong>question marks</strong> or may be changed for an <strong>approximate</strong> character, because, they do <strong>not</strong> belong to the the corresponding <strong>ANSI</strong> table of <strong><code>256</code></strong> characters !</p>
<p dir="auto">For instance, in my <strong>previous</strong> list of rivers, the Turkish <strong><code>Kızılırmak</code></strong> river, containing the Latin <strong>lowercase pointless</strong> letter <strong><code>ı</code></strong>, ( of code-point <strong><code>\x{0131}</code></strong> ), is changed into the <strong>approximate</strong> name <strong><code>Kizilirmak</code></strong>, after conversion to <strong><code>ANSI</code></strong> !</p>
<p dir="auto">Anyway, we just did our <strong>best</strong> to solve the <strong>OP</strong>’s problem ;-))</p>
<p dir="auto">BR</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/45594</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/45594</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Wed, 24 Jul 2019 18:21:36 GMT</pubDate></item><item><title><![CDATA[Reply to File sorting on Wed, 24 Jul 2019 14:34:43 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@Alan-Kilborn</a> said:</p>
<blockquote>
<p dir="auto">The Python len function is apparently simple-minded in this case</p>
</blockquote>
<p dir="auto">Perhaps this new one-liner is better, for the case where the OP has Unicode data:</p>
<pre><code>editor.setText(['\r\n','\r','\n'][editor.getEOLMode()].join(sorted(editor.getText().splitlines(),key=lambda x:len(unicode(x,'utf-8')))))
</code></pre>
<p dir="auto">Of course, still big assumption that the OP is using (or is willing to use) Pythonscript! ;)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/45585</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/45585</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Wed, 24 Jul 2019 14:34:43 GMT</pubDate></item><item><title><![CDATA[Reply to File sorting on Wed, 24 Jul 2019 13:45:32 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a> said:</p>
<blockquote>
<p dir="auto">names are not sorted alphabetically</p>
</blockquote>
<p dir="auto">This is outside the scope of the originally stated problem!  :)</p>
<blockquote>
<p dir="auto">containing accentuated characters…are located outside their section</p>
</blockquote>
<p dir="auto">The Python <code>len</code> function is apparently simple-minded in this case (using a simple byte count for the length of these strings containing multibyte characters).</p>
]]></description><link>https://community.notepad-plus-plus.org/post/45582</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/45582</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Wed, 24 Jul 2019 13:45:32 GMT</pubDate></item><item><title><![CDATA[Reply to File sorting on Wed, 24 Jul 2019 13:38:14 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/15933">@dave-pruce</a>, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@alan-kilborn</a> and <strong>All</strong>,</p>
<p dir="auto">My <strong>previous</strong> list of rivers contained <strong><code>5</code></strong> <strong>duplicate</strong> names :</p>
<p dir="auto"><strong><code>Red</code></strong>, <strong><code>Murray</code></strong>, <strong><code>Yenisei</code></strong>, <strong><code>Araguaia</code></strong> and <strong><code>Colorado</code></strong></p>
<p dir="auto">But this is <strong>not</strong> important, regarding our problem, anyway !</p>
<p dir="auto">As you can see, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/15933">@<a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/15933">@dave-pruce</a></a>, the <strong>Python</strong> solution, from <strong>Alan</strong>, is <strong>neater</strong> ! Isn’t it ?</p>
<hr />
<p dir="auto">Now, <strong>Alan</strong>, I’ve just tested your <strong>one-line</strong> script and, to my mind, there’s <strong>two</strong> problems :</p>
<ul>
<li>
<p dir="auto">Inside a <strong>section</strong> of river names, of a <strong>same</strong> length, the names are <strong>not</strong> sorted alphabetically !</p>
</li>
<li>
<p dir="auto">Secondly, some names, containing <strong>accentuated</strong> characters, as, for instance, the <strong><code>Içá</code></strong> river, are located outside their section, as noticed, below :</p>
</li>
</ul>
<pre><code class="language-diff">Snake
Volta
Tobol
Jubba
Içá
Pecos
Benue
Iriri
Lerma
</code></pre>
<p dir="auto">Cheers,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/45581</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/45581</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Wed, 24 Jul 2019 13:38:14 GMT</pubDate></item><item><title><![CDATA[Reply to File sorting on Wed, 24 Jul 2019 13:32:11 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a> said:</p>
<blockquote>
<p dir="auto">Hey, guys, it’s not a competition, OK !</p>
</blockquote>
<p dir="auto">Haha.  No, definitely not.  A support forum is about giving posters options to solving problems where there is not a very clear answer.  It seems we’ve done that so far in this thread!  :)</p>
<p dir="auto">BTW, that was what I anticipated:  A lot of manual steps.  :)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/45580</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/45580</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Wed, 24 Jul 2019 13:32:11 GMT</pubDate></item><item><title><![CDATA[Reply to File sorting on Wed, 24 Jul 2019 13:07:46 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/15933">@dave-pruce</a>, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@alan-kilborn</a> and <strong>All</strong>,</p>
<p dir="auto">The work-around comes from a <strong>simple</strong> idea. Imagine these <strong><code>5</code></strong> lines, below !</p>
<pre><code class="language-diff">wxyz
defghijklm
no
abcd
pqrstuv
</code></pre>
<p dir="auto">To begin with, <strong>right</strong> justify these <strong><code>5</code></strong> lines. So you get :</p>
<pre><code class="language-diff">      wxyz
defghijklm
        no
      abcd
   pqrstuv
</code></pre>
<p dir="auto">Now, run a simple <strong>ascending alphabetic</strong> sort</p>
<pre><code class="language-diff">        no
      abcd
      wxyz
   pqrstuv
defghijklm
</code></pre>
<p dir="auto">Nice ! We have, <strong>automatically</strong>, all the lines sorted by <strong>line length</strong>.</p>
<p dir="auto">To end, you just have to get rid of the <strong>leading spaces</strong>, giving the <strong>expected</strong> text :</p>
<pre><code class="language-diff">no
abcd
wxyz
pqrstuv
defghijklm
</code></pre>
<p dir="auto">In addition, notice that lines of <strong>same length</strong> are, also, <strong>sorted</strong> alphabetically, too ;-))</p>
<hr />
<p dir="auto">OK ! Let’s use a <strong>real</strong> list. From, the link, below :</p>
<p dir="auto"><a href="https://en.wikipedia.org/wiki/List_of_rivers_by_length" rel="nofollow ugc">https://en.wikipedia.org/wiki/List_of_rivers_by_length</a></p>
<p dir="auto">I got, for instance, after some re-formating, an <strong>English</strong> world list of <strong><code>243</code></strong> rivers, below, <strong>pasted</strong> in a <strong>new</strong> N++ tab :</p>
<pre><code class="language-diff">Nile
White Nile
Kagera
Nyabarongo
Mwogo
Rukarara
Amazon
Ucayali
Tambo
Ene
Mantaro
Yangtze
Mississippi
Missouri
Jefferson
Beaverhead
Red Rock
Hell Roaring
Yenisei
Angara
Selenge
Ider
Yellow River
Ob
Irtysh
Río de la Plata
Paraná
Congo
Chambeshi
Amur
Argun
Kherlen
Lena
Mekong
Mackenzie
Slave
Peace
Finlay
Niger
Brahmaputra
Tsangpo
Murray
Darling
Culgoa
Balonne
Condamine
Tocantins
Araguaia
Volga
Indus
Sênggê Zangbo
Shatt al-Arab
Euphrates
Murat
Madeira
Mamoré
Caine
Rocha
Purús
Yukon
São Francisco
Syr Darya
Naryn
Salween
Saint Lawrence
Niagara
Detroit
Saint Clair
Saint Marys
Saint Louis
North
Nizhnyaya Tunguska
Danube
Breg
Zambezi
Vilyuy
Araguaia
Ganges
Hooghly
Padma
Amu Darya
Panj
Japurá
Nelson
Saskatchewan
Paraguay
Kolyma
Pilcomayo
Biya
Katun
Ishim
Juruá
Ural
Arkansas
Colorado
Olenyok
Dnieper
Aldan
Ubangi
Uele
Negro
Columbia
Zhujiang
Red
Ayeyarwady
Kasai
Ohio
Allegheny
Orinoco
Tarim
Xingu
Orange
Salado
Vitim
Tigris
Songhua
Tapajós
Don
Podkamennaya Tunguska
Pechora
Kama
Limpopo
Chulym
Guaporé
Indigirka
Snake
Senegal
Uruguay
Blue Nile
Churchill
Khatanga
Okavango
Volta
Beni
Platte
Tobol
Alazeya
Jubba
Shebelle
Içá
Magdalena
Han
Kura
Oka
Murray
Guaviare
Pecos
Murrumbidgee
Yenisei
Godavari
Colorado
Río Grande
Belaya
Cooper
Barcoo
Marañón
Dniester
Benue
Ili
Warburton
Georgina
Sutlej
Yamuna
Vyatka
Fraser
Brazos
Liao
Lachlan
Yalong
Iguaçu
Olyokma
Northern Dvina
Sukhona
Krishna
Iriri
Narmada
Lomami
Ottawa
Lerma
Grande de Santiago
Elbe
Vltava
Zeya
Juruena
Rhine
Athabasca
Canadian
North Saskatchewan
Vistula
Bug
Vaal
Shire
Ogooué
Nen
Kızılırmak
Markha
Green
Milk
Chindwin
Sankuru
Wu
Red
James
Kapuas
Desna
Helmand
Madre de Dios
Tietê
Vychegda
Sepik
Cimarron
Anadyr
Paraíba do Sul
Jialing
Liard
Cumberland
White
Huallaga
Kwango
Draa
Gambia
Tyung
Chenab
Yellowstone
Ghaghara
Huai
Aras
Chu
Seversky Donets
Bermejo
Fly
Kuskokwim
Tennessee
Oder
Warta
Aruwimi
Daugava
Gila
Loire
Essequibo
Khoper
Tagus
Flinders
</code></pre>
<p dir="auto">Ironically, we’re going to <strong>classify</strong> them, according to the <strong>length</strong> of their <strong>name</strong> and <strong>not</strong> according to their <strong>length</strong> ;-))</p>
<hr />
<p dir="auto">First, we’ll, roughly, <strong>estimate</strong> the <strong>maximum length</strong> of the listed names, with the <strong>generic</strong> regex <strong><code>(?-s)^.{</code>N<code>,}</code></strong></p>
<ul>
<li>
<p dir="auto">Open the <strong><code>Replace</code></strong>  window ( <strong><code>Ctrl + H</code></strong> )</p>
</li>
<li>
<p dir="auto">Select the <strong><code>Regular expression </code></strong> search mode</p>
<ul>
<li>
<p dir="auto"><strong><code>(?-s)^.{30,}</code></strong> and a click on the <strong><code>Count</code></strong> button =&gt;  <strong><code>0</code></strong> matches</p>
</li>
<li>
<p dir="auto"><strong><code>(?-s)^.{25,}</code></strong> and a click on the <strong><code>Count</code></strong> button =&gt;  <strong><code>0</code></strong> matches</p>
</li>
<li>
<p dir="auto"><strong><code>(?-s)^.{20,}</code></strong> and a click on the <strong><code>Count</code></strong> button =&gt;  <strong><code>1</code></strong> match</p>
</li>
</ul>
</li>
</ul>
<p dir="auto">=&gt; The maximum length is between <strong><code>20</code></strong> and <strong><code>25</code></strong>. So, we’ll rely on the <strong>upper</strong> boundary <strong><code>25</code></strong> in the <strong>subsequent</strong> regexes :</p>
<hr />
<p dir="auto">For all the <strong>subsequent</strong> regex S/R :</p>
<ul>
<li>
<p dir="auto">Tick the <strong><code>Wrap around</code></strong> option</p>
</li>
<li>
<p dir="auto">Click on the <strong><code>Replace All</code></strong> button, <strong>exclusively</strong>, to process each <strong>S/R</strong></p>
</li>
</ul>
<p dir="auto">We’ll begin to add <strong><code>25</code></strong> <strong>space</strong> chars, at <strong>end</strong> of each line of the list :</p>
<p dir="auto">SEARCH <strong><code>(?-s)^.+</code></strong></p>
<p dir="auto">REPLACE <strong><code>$0</code></strong> ( and type in <strong><code>25</code></strong> <strong>space</strong> characters, right after <strong><code>$0</code></strong>, in the <strong>Replace</strong> zone</p>
<p dir="auto"><strong>Note</strong> : In case, you would need, for an other list, <strong>additional space</strong> chars, at <strong>end</strong> of lines, just <strong>re-run</strong> this S/R to get <strong><code>50</code></strong>, <strong><code>75</code></strong>, <strong><code>100</code></strong>, <strong>spaces</strong> and so on !</p>
<hr />
<p dir="auto">Then, use the following <strong>regex</strong> S/R, in order to <strong>truncate</strong> any <strong>standard</strong> character, located <strong>after</strong> the <strong><code>25</code></strong> column :</p>
<p dir="auto">SEARCH <strong><code>(?-s)^.{25}\K.+</code></strong></p>
<p dir="auto">REPLACE <strong><code>Leave EMPTY</code></strong></p>
<hr />
<p dir="auto">Now, we’re going to <strong>right justify</strong> all these names, with the <strong>regex</strong> S/R :</p>
<p dir="auto">SEARCH <strong><code>(?-s)^(.+?)(\x20{2,})$</code></strong></p>
<p dir="auto">REPLACE   <strong><code>\2\1</code></strong></p>
<p dir="auto">You should get the following text ( I simply put the <strong>beginning</strong> and <strong>end</strong> of the list, in order to <strong>limit</strong> my post <strong>length</strong> ! ) :</p>
<pre><code class="language-diff">                     Nile
               White Nile
                   Kagera
               Nyabarongo
                    Mwogo
                 Rukarara
                   Amazon
                  Ucayali
                    Tambo
                      Ene
.........................
.........................
.........................
                     Oder
                    Warta
                  Aruwimi
                  Daugava
                     Gila
                    Loire
                Essequibo
                   Khoper
                    Tagus
                 Flinders
</code></pre>
<p dir="auto">Now, we perform the usual <strong>alphabetic</strong> sort ( <strong><code>Edit &gt; Line Operations &gt; Sort Lines Lexicographically Ascending</code></strong> ) and we get :</p>
<pre><code class="language-diff">                       Ob
                       Wu
                      Bug
                      Chu
                      Don
                      Ene
                      Fly
                      Han
                      Ili
                      Içá
                      Nen
                      Oka
                      Red
                      Red
                     Amur
                     Aras
                     Beni
.........................
.........................
.........................
             Hell Roaring
             Murrumbidgee
             Saskatchewan
             Yellow River
            Madre de Dios
            Shatt al-Arab
            São Francisco
            Sênggê Zangbo
           Northern Dvina
           Paraíba do Sul
           Saint Lawrence
          Río de la Plata
          Seversky Donets
       Grande de Santiago
       Nizhnyaya Tunguska
       North Saskatchewan
    Podkamennaya Tunguska
</code></pre>
<hr />
<p dir="auto">To end, we get rid of all the <strong>leading spaces</strong>, with :</p>
<p dir="auto">SEARCH <strong><code>^\x20+</code></strong></p>
<p dir="auto">REPLACE <strong><code>Leave EMPTY</code></strong></p>
<p dir="auto">and we get our <strong>expected</strong> list :</p>
<pre><code class="language-diff">Ob
Wu
Bug
Chu
Don
Ene
Fly
Han
Ili
Içá
Nen
Oka
Red
Red
Amur
Aras
Beni
Biya
Breg
Draa
..............
..............
..............
Saint Louis
Saint Marys
Yellowstone
Hell Roaring
Murrumbidgee
Saskatchewan
Yellow River
Madre de Dios
Shatt al-Arab
São Francisco
Sênggê Zangbo
Northern Dvina
Paraíba do Sul
Saint Lawrence
Río de la Plata
Seversky Donets
Grande de Santiago
Nizhnyaya Tunguska
North Saskatchewan
Podkamennaya Tunguska
</code></pre>
<hr />
<p dir="auto">Note that this kind of text <strong>manipulation</strong> should certainly be programmed, in a more <strong>elegant</strong> way, with a <strong>Python</strong> or <strong>Lua</strong> script ;-)) Unfortunately, my skills in that matter are quite <strong>poor</strong> :-((</p>
<p dir="auto">However, I’m sure that some gurus, as <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@alan-kilborn</a>, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/14479">@ekopalypse</a> <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/3841">@peterjones</a> or <strong>dail</strong>, will probably be able to give you a <strong>script</strong> solution, that, of course, will require you to install the <strong>Python</strong> or <strong>Lua</strong> interpreter !</p>
<p dir="auto">Hey, guys, it’s not a <strong>competition</strong>, OK !</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/45577</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/45577</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Wed, 24 Jul 2019 13:07:46 GMT</pubDate></item><item><title><![CDATA[Reply to File sorting on Wed, 24 Jul 2019 12:56:19 GMT]]></title><description><![CDATA[<p dir="auto">While we’re waiting for <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a>, while not native to Notepad++, a Pythonscript one-liner can do the job:</p>
<pre><code>editor.setText(['\r\n','\r','\n'][editor.getEOLMode()].join(sorted(editor.getText().splitlines(),key=len)))
</code></pre>
<p dir="auto">And since it is a one-liner, one doesn’t even have to create a file for it.  Just open a Pythonscript Console window (Plugins &gt; Pythonscript &gt; Show Console) and then find the little box that has <code>&gt;&gt;&gt;</code> to its left in the console window and paste the above there.  Press Enter to execute it for the active Notepad++ file.</p>
<p dir="auto">Sadly, the bigger hurdle would be getting Pythonscript installed.  :-(</p>
]]></description><link>https://community.notepad-plus-plus.org/post/45576</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/45576</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Wed, 24 Jul 2019 12:56:19 GMT</pubDate></item><item><title><![CDATA[Reply to File sorting on Wed, 24 Jul 2019 12:42:29 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a></p>
<p dir="auto">I’ll have to see the number of steps involved to see if it invalidates my original “no”.  :)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/45575</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/45575</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Wed, 24 Jul 2019 12:42:29 GMT</pubDate></item><item><title><![CDATA[Reply to File sorting on Tue, 23 Jul 2019 23:50:49 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/15933">@dave-pruce</a>, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@alan-kilborn</a> and <strong>All</strong>,</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/15933">@dave-pruce</a> :</p>
<p dir="auto">Still, as gently as possible, I can whisper to you : There a possible <strong>work-around</strong>, which <strong>only</strong> uses <strong>native</strong> N++ features ;-))</p>
<p dir="auto">As it’s about <strong><code>1.40 a.m</code></strong>, presently, in France, I hope to be able to post my solution, <strong>tomorrow</strong>. So just be patient, a while !</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/45572</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/45572</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Tue, 23 Jul 2019 23:50:49 GMT</pubDate></item><item><title><![CDATA[Reply to File sorting on Tue, 23 Jul 2019 13:02:12 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/15933">@Dave-Pruce</a></p>
<p dir="auto">As gently as possible…quiet now…here it comes:  no (sorry), not with Notepad++ itself.</p>
<p dir="auto">A lot of other ways, though: think “programming”.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/45564</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/45564</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Tue, 23 Jul 2019 13:02:12 GMT</pubDate></item></channel></rss>