<?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[Sorting multiple chunks of non-connected text]]></title><description><![CDATA[<p dir="auto">How do I sort disparate chunks of text across a large document?<br />
Is a macro going to be the best option?</p>
<p dir="auto">Bounds would be (everything between):<br />
Member of groups:</p>
<p dir="auto">to</p>
<hr />
<p dir="auto">#########################</p>
<p dir="auto">Name:                           asd0<br />
Comment:                        name<br />
Member of groups:<br />
PDOC_R<br />
VOUCHER_R<br />
RDOC_R</p>
<hr />
<p dir="auto">Name:                           wr3<br />
Comment:                        name<br />
Member of groups:<br />
PDOC_R<br />
SPURCHASE_R<br />
RDOC_R<br />
RDOC_RW<br />
SRECEIVE_RWX<br />
RDOC_RWX<br />
SRECEIVE_R</p>
<hr />
<p dir="auto">Name:                           ft3<br />
Comment:                        name<br />
Member of groups:<br />
PDOC_R<br />
RDOC_R<br />
SORMPURCHASING_R<br />
SORMRECEIVING_R<br />
SORMVOUCHERS_R<br />
VOUCHER_R</p>
<hr />
<p dir="auto">Name:                           grt<br />
Comment:                        name<br />
Member of groups:<br />
TRAVEL_R<br />
PDOC_R<br />
SPURCHASE_R<br />
VOUCHER_R<br />
SVOUCHER_R<br />
RDOC_R<br />
SRECEIVE_R<br />
CONTRACT_R<br />
Lease_R</p>
<hr />
<p dir="auto">Name:                           asdq<br />
Comment:                        name<br />
Member of groups:<br />
PDOC_R<br />
VOUCHER_R<br />
RDOC_R</p>
<hr />
<p dir="auto">Name:                           jkl1<br />
Comment:                        name<br />
Member of groups:<br />
TRAVEL_R<br />
STRAVEL_R<br />
PDOC_R<br />
SPURCHASE_R<br />
VOUCHER_R<br />
SVOUCHER_R<br />
RDOC_R<br />
SRECEIVE_R<br />
CONTRACT_R</p>
<hr />
]]></description><link>https://community.notepad-plus-plus.org/topic/15971/sorting-multiple-chunks-of-non-connected-text</link><generator>RSS for Node</generator><lastBuildDate>Sat, 06 Jun 2026 01:28:47 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/15971.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 26 Jun 2018 22:58:30 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Sorting multiple chunks of non-connected text on Fri, 06 Jul 2018 20:29:31 GMT]]></title><description><![CDATA[<p dir="auto">That was utter brilliance <a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a> . I, i can’t even. Hats off on that.<br />
(This is not to say that the py script from <a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a> is out the window, this will just help me convince folks that Notepad++ is the best.)  :)</p>
<p dir="auto">+++Unrelated+++<br />
So, is there a book, like NoStarchPress or something for Notepad++? How did you learn all these fancy bits for the regex? (its Perl?)<br />
Python vs. Perl? (I’d like to learn one, or both. My aim is system administration/automation. Recommendations?)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/33372</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/33372</guid><dc:creator><![CDATA[Jeff Test]]></dc:creator><pubDate>Fri, 06 Jul 2018 20:29:31 GMT</pubDate></item><item><title><![CDATA[Reply to Sorting multiple chunks of non-connected text on Thu, 05 Jul 2018 18:44:05 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="/user/jeff-test" aria-label="Profile: jeff-test">@<bdi>jeff-test</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: peterjones">@<bdi>peterjones</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">Sorry for this <strong>late</strong> reply, but I was with my sister and brother-in-law, a couple of days !</p>
<hr />
<p dir="auto">So, here is, below, my solution, just using <strong>regex</strong> S/R and a N++ <strong>sort</strong> ! Of course, the <strong>Python</strong> script, from <strong>Peter</strong> is <strong>easier</strong> to use and, probably, <strong>quicker</strong> than all my stuff ! Just <strong>one</strong> advantage : this method can be processed with a <strong>minimalist N++ package</strong> Ah, Ah -;))</p>
<p dir="auto">So, starting with this <strong>sample</strong> text, below, in a <strong>new</strong> N++ tab :</p>
<pre><code class="language-diff">Name: asd0
Comment: name
Member of groups:
PDOC_R
VOUCHER_R
RDOC_R

Name: wr3
Comment: name
Member of groups:
PDOC_R
SPURCHASE_R
RDOC_R
RDOC_RW
SRECEIVE_RWX
RDOC_RWX
SRECEIVE_R

Name: ft3
Comment: name
Member of groups:
PDOC_R
RDOC_R
SORMPURCHASING_R
SORMRECEIVING_R
SORMVOUCHERS_R
VOUCHER_R

Name: grt
Comment: name
Member of groups:
TRAVEL_R
PDOC_R
SPURCHASE_R
VOUCHER_R
SVOUCHER_R
RDOC_R
SRECEIVE_R
CONTRACT_R
Lease_R

Name: asdq
Comment: name
Member of groups:
PDOC_R
VOUCHER_R
RDOC_R

Name: jkl1
Comment: name
Member of groups:
TRAVEL_R
STRAVEL_R
PDOC_R
SPURCHASE_R
VOUCHER_R
SVOUCHER_R
RDOC_R
SRECEIVE_R
CONTRACT_R
</code></pre>
<p dir="auto">Firstly, add, if necessary, an <strong>empty</strong> line at the <strong>very end</strong> of the list</p>
<hr />
<p dir="auto">Now, if we use the following <strong>regex</strong> S/R, which copies the <strong>name</strong> of each group, <strong>preceded</strong> by the <strong><code>#</code></strong> symbol, in a <strong>new</strong> line, located <strong>after</strong> the <strong>corresponding</strong> group :</p>
<p dir="auto">SEARCH <strong><code>(?s-i)^Name:\x20(.+?\R).+?\R(?=\R|\z)</code></strong></p>
<p dir="auto">REPLACE <strong><code>$0#\1</code></strong></p>
<p dir="auto">we get the text :</p>
<pre><code class="language-diff">Name: asd0
Comment: name
Member of groups:
PDOC_R
VOUCHER_R
RDOC_R
#asd0

Name: wr3
Comment: name
Member of groups:
PDOC_R
SPURCHASE_R
RDOC_R
RDOC_RW
SRECEIVE_RWX
RDOC_RWX
SRECEIVE_R
#wr3

Name: ft3
Comment: name
Member of groups:
PDOC_R
RDOC_R
SORMPURCHASING_R
SORMRECEIVING_R
SORMVOUCHERS_R
VOUCHER_R
#ft3

Name: grt
Comment: name
Member of groups:
TRAVEL_R
PDOC_R
SPURCHASE_R
VOUCHER_R
SVOUCHER_R
RDOC_R
SRECEIVE_R
CONTRACT_R
Lease_R
#grt

Name: asdq
Comment: name
Member of groups:
PDOC_R
VOUCHER_R
RDOC_R
#asdq

Name: jkl1
Comment: name
Member of groups:
TRAVEL_R
STRAVEL_R
PDOC_R
SPURCHASE_R
VOUCHER_R
SVOUCHER_R
RDOC_R
SRECEIVE_R
CONTRACT_R
#jkl1
</code></pre>
<p dir="auto">Then, using this <strong>second</strong> regex S/R, which adds a <strong>prefix</strong> to <strong>each</strong> line of the list, depending on its <strong>type</strong> :</p>
<p dir="auto">SEARCH <strong><code>(?-si)^((?:(Name:)|(Comment:)|(Member\x20)|(.+_)).+)(?=(?:(?s).+?)#(.+))|^#(.+)\R?</code></strong></p>
<p dir="auto">REPLACE <strong><code>(?2\6_1_\1)(?3\6_2_\1)(?4\6_3_\1)(?5\6_4_\1)(?7\7_5_)</code></strong></p>
<p dir="auto">we obtain :</p>
<pre><code class="language-diff">asd0_1_Name: asd0
asd0_2_Comment: name
asd0_3_Member of groups:
asd0_4_PDOC_R
asd0_4_VOUCHER_R
asd0_4_RDOC_R
asd0_5_
wr3_1_Name: wr3
wr3_2_Comment: name
wr3_3_Member of groups:
wr3_4_PDOC_R
wr3_4_SPURCHASE_R
wr3_4_RDOC_R
wr3_4_RDOC_RW
wr3_4_SRECEIVE_RWX
wr3_4_RDOC_RWX
wr3_4_SRECEIVE_R
wr3_5_
ft3_1_Name: ft3
ft3_2_Comment: name
ft3_3_Member of groups:
ft3_4_PDOC_R
ft3_4_RDOC_R
ft3_4_SORMPURCHASING_R
ft3_4_SORMRECEIVING_R
ft3_4_SORMVOUCHERS_R
ft3_4_VOUCHER_R
ft3_5_
grt_1_Name: grt
grt_2_Comment: name
grt_3_Member of groups:
grt_4_TRAVEL_R
grt_4_PDOC_R
grt_4_SPURCHASE_R
grt_4_VOUCHER_R
grt_4_SVOUCHER_R
grt_4_RDOC_R
grt_4_SRECEIVE_R
grt_4_CONTRACT_R
grt_4_Lease_R
grt_5_
asdq_1_Name: asdq
asdq_2_Comment: name
asdq_3_Member of groups:
asdq_4_PDOC_R
asdq_4_VOUCHER_R
asdq_4_RDOC_R
asdq_5_
jkl1_1_Name: jkl1
jkl1_2_Comment: name
jkl1_3_Member of groups:
jkl1_4_TRAVEL_R
jkl1_4_STRAVEL_R
jkl1_4_PDOC_R
jkl1_4_SPURCHASE_R
jkl1_4_VOUCHER_R
jkl1_4_SVOUCHER_R
jkl1_4_RDOC_R
jkl1_4_SRECEIVE_R
jkl1_4_CONTRACT_R
jkl1_5_
</code></pre>
<hr />
<p dir="auto">Now, we perform the usual <strong>sort</strong>, using the menu command <strong><code>Edit &gt; Line Operations &gt; Sort Lines Lexicographically Ascending</code></strong></p>
<p dir="auto">which gives the following text :</p>
<pre><code class="language-diff">asd0_1_Name: asd0
asd0_2_Comment: name
asd0_3_Member of groups:
asd0_4_PDOC_R
asd0_4_RDOC_R
asd0_4_VOUCHER_R
asd0_5_
asdq_1_Name: asdq
asdq_2_Comment: name
asdq_3_Member of groups:
asdq_4_PDOC_R
asdq_4_RDOC_R
asdq_4_VOUCHER_R
asdq_5_
ft3_1_Name: ft3
ft3_2_Comment: name
ft3_3_Member of groups:
ft3_4_PDOC_R
ft3_4_RDOC_R
ft3_4_SORMPURCHASING_R
ft3_4_SORMRECEIVING_R
ft3_4_SORMVOUCHERS_R
ft3_4_VOUCHER_R
ft3_5_
grt_1_Name: grt
grt_2_Comment: name
grt_3_Member of groups:
grt_4_CONTRACT_R
grt_4_Lease_R
grt_4_PDOC_R
grt_4_RDOC_R
grt_4_SPURCHASE_R
grt_4_SRECEIVE_R
grt_4_SVOUCHER_R
grt_4_TRAVEL_R
grt_4_VOUCHER_R
grt_5_
jkl1_1_Name: jkl1
jkl1_2_Comment: name
jkl1_3_Member of groups:
jkl1_4_CONTRACT_R
jkl1_4_PDOC_R
jkl1_4_RDOC_R
jkl1_4_SPURCHASE_R
jkl1_4_SRECEIVE_R
jkl1_4_STRAVEL_R
jkl1_4_SVOUCHER_R
jkl1_4_TRAVEL_R
jkl1_4_VOUCHER_R
jkl1_5_
wr3_1_Name: wr3
wr3_2_Comment: name
wr3_3_Member of groups:
wr3_4_PDOC_R
wr3_4_RDOC_R
wr3_4_RDOC_RW
wr3_4_RDOC_RWX
wr3_4_SPURCHASE_R
wr3_4_SRECEIVE_R
wr3_4_SRECEIVE_RWX
wr3_5_
</code></pre>
<p dir="auto">And, finally, we <strong>get rid of</strong> all the <strong>prefixes</strong>, in <strong>all</strong> the lines of the list. Very <strong>easy</strong> with the simple S/R, below :</p>
<p dir="auto">SEARCH <strong><code>^.+_\d_</code></strong></p>
<p dir="auto">REPLACE <strong><code>Leave EMPTY</code></strong></p>
<p dir="auto">So, we are left with :</p>
<pre><code class="language-diff">Name: asd0
Comment: name
Member of groups:
PDOC_R
RDOC_R
VOUCHER_R

Name: asdq
Comment: name
Member of groups:
PDOC_R
RDOC_R
VOUCHER_R

Name: ft3
Comment: name
Member of groups:
PDOC_R
RDOC_R
SORMPURCHASING_R
SORMRECEIVING_R
SORMVOUCHERS_R
VOUCHER_R

Name: grt
Comment: name
Member of groups:
CONTRACT_R
Lease_R
PDOC_R
RDOC_R
SPURCHASE_R
SRECEIVE_R
SVOUCHER_R
TRAVEL_R
VOUCHER_R

Name: jkl1
Comment: name
Member of groups:
CONTRACT_R
PDOC_R
RDOC_R
SPURCHASE_R
SRECEIVE_R
STRAVEL_R
SVOUCHER_R
TRAVEL_R
VOUCHER_R

Name: wr3
Comment: name
Member of groups:
PDOC_R
RDOC_R
RDOC_RW
RDOC_RWX
SPURCHASE_R
SRECEIVE_R
SRECEIVE_RWX
</code></pre>
<p dir="auto"><strong>Remark</strong> :</p>
<p dir="auto">Just notice that, <strong>both</strong> :</p>
<ul>
<li>
<p dir="auto">The different groups are <strong>alphabetically sorted</strong></p>
</li>
<li>
<p dir="auto">The list of all the <strong>members</strong>, in <strong>each</strong> group, is also, <strong>alphabetically sorted</strong></p>
</li>
</ul>
<p dir="auto">Cheers,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/33345</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/33345</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Thu, 05 Jul 2018 18:44:05 GMT</pubDate></item><item><title><![CDATA[Reply to Sorting multiple chunks of non-connected text on Tue, 03 Jul 2018 17:38:05 GMT]]></title><description><![CDATA[<p dir="auto">So, assuming you have the <a href="http://sourceforge.net/projects/npppythonscript/files/Python%20Script%201.0.8.0/PythonScript_1.0.8.0.msi/download" rel="nofollow ugc">Python Script Plugin</a>…</p>
<ol>
<li>
<p dir="auto">Create the script: <code>Plugins &gt; Python Script &gt; New Script</code></p>
</li>
<li>
<p dir="auto">Paste the script, and save with meaningful name: <code>sortGroups.py</code></p>
<pre><code> #https://notepad-plus-plus.org/community/topic/15971/sorting-multiple-chunks-of-non-connected-text/4
 # works on active view / file
 import sys
 from Npp import *

 console.clear()
 #console.show()

 # for debug, change view and document index
 #i = notepad.getCurrentDocIndex(1)
 #notepad.activateIndex(1,i)

 keepGoing = True

 editor.documentEnd()               # go to the last position
 end2 = editor.getCurrentPos()      # record the position
 #console.write("editor.end = " + str(end2)+"\n")
 editor.documentStart()             # back to the beginning
 start2 = editor.getCurrentPos()    # record the position
 #console.write("editor.start = " + str(start2)+"\n")

 while keepGoing:
     # find the group:\R prefix
     position = editor.findText( FINDOPTION.REGEXP, start2, end2, "groups:$")
     if position is None:
         break
     #console.write("editor: findText @ " + str(position[0]) + ":" + str(position[1]) + "\n")

     # find ___ (or EOF)
     underscore = editor.findText( FINDOPTION.REGEXP, position[1], end2, "^_+$")
     if underscore is None:
         keepGoing = False
         underscore = (end2, end2)

     # select the text
     #console.write("editor: findText @ " + str(underscore[0]) + ":" + str(underscore[1]) + "\n")
     editor.setSelectionStart(position[1]+2)    # start after the newline
     editor.setSelectionEnd(underscore[0]-2)    # end before the newline

     # okay, now the first match is highlighted... need to run the Edit &gt; Line Operations &gt; Sort Lines Lexicographically Ascending...
     # maybe notepad.menuCommand() or notepad.runMenuCommand()
     notepad.menuCommand(42059)  # got from https://github.com/notepad-plus-plus/notepad-plus-plus/blob/master/PowerEditor/installer/nativeLang/english.xml
     #console.write(str(keepGoing))

     # start at the end of the last group
     start2 = underscore[0]

 # want nothing selected at end
 editor.clearSelections()
</code></pre>
</li>
<li>
<p dir="auto">Input file (make sure this is the active window / view / document in Notepad++)</p>
<pre><code> Name: jkl1
 Comment: name
 Member of groups:
     STRAVEL_R
     PDOC_R
     TRAVEL_R
 _______________________________________________________________________________
 Name: abc3
 Comment: name
 Member of groups:
     SPURCHASE_R
     VOUCHER_R
     SVOUCHER_R
 _______________________________________________________________________________
 Name: xyz9
 Comment: name
 Member of groups:
     RDOC_R
     SRECEIVE_R
     CONTRACT_R
 _______________________________________________________________________________
 Name: abc1
 Comment: name
 Member of groups:
     TRAVEL_R
     VOUCHER_R
     SVOUCHER_R
 _______________________________________________________________________________
</code></pre>
</li>
<li>
<p dir="auto"><code>Plugins &gt; Python Script &gt; Scripts &gt; sortGroups.py</code></p>
</li>
<li>
<p dir="auto">Result:</p>
<pre><code> Name: jkl1
 Comment: name
 Member of groups:
     PDOC_R
     STRAVEL_R
     TRAVEL_R
 _______________________________________________________________________________
 Name: abc3
 Comment: name
 Member of groups:
     SPURCHASE_R
     SVOUCHER_R
     VOUCHER_R
 _______________________________________________________________________________
 Name: xyz9
 Comment: name
 Member of groups:
     CONTRACT_R
     RDOC_R
     SRECEIVE_R
 _______________________________________________________________________________
 Name: abc1
 Comment: name
 Member of groups:
     SVOUCHER_R
     TRAVEL_R
     VOUCHER_R
 _______________________________________________________________________________
</code></pre>
</li>
</ol>
<p dir="auto">I think this does what you want.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/33308</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/33308</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Tue, 03 Jul 2018 17:38:05 GMT</pubDate></item><item><title><![CDATA[Reply to Sorting multiple chunks of non-connected text on Tue, 03 Jul 2018 15:36:21 GMT]]></title><description><![CDATA[<p dir="auto">Yes. Each block: doesnt matter what order they are in, as long as each user remains with their listed access. However, each little list of ‘groups’ needs to be sorted, such as <a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a> has stated/shown.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/33307</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/33307</guid><dc:creator><![CDATA[Jeff Test]]></dc:creator><pubDate>Tue, 03 Jul 2018 15:36:21 GMT</pubDate></item><item><title><![CDATA[Reply to Sorting multiple chunks of non-connected text on Sat, 30 Jun 2018 03:00:00 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/jeff-test" aria-label="Profile: jeff-test">@<bdi>jeff-test</bdi></a>,</p>
<p dir="auto">Do you expect an <strong>output</strong> text like below, where <strong>each</strong> block of <strong>member</strong> names, containing the <strong><code>_</code></strong> character, is <strong>sorted</strong> ?</p>
<pre><code class="language-diff">#########################

Name: asd0
Comment: name
Member of groups:
PDOC_R
RDOC_R
VOUCHER_R

Name: wr3
Comment: name
Member of groups:
PDOC_R
RDOC_R
RDOC_RW
RDOC_RWX
SPURCHASE_R
SRECEIVE_R
SRECEIVE_RWX

Name: ft3
Comment: name
Member of groups:
PDOC_R
RDOC_R
SORMPURCHASING_R
SORMRECEIVING_R
SORMVOUCHERS_R
VOUCHER_R

Name: grt
Comment: name
Member of groups:
CONTRACT_R
Lease_R
PDOC_R
RDOC_R
SPURCHASE_R
SRECEIVE_R
SVOUCHER_R
TRAVEL_R
VOUCHER_R

Name: asdq
Comment: name
Member of groups:
PDOC_R
RDOC_R
VOUCHER_R

Name: jkl1
Comment: name
Member of groups:
CONTRACT_R
PDOC_R
RDOC_R
SPURCHASE_R
SRECEIVE_R
STRAVEL_R
SVOUCHER_R
TRAVEL_R
VOUCHER_R
</code></pre>
<p dir="auto">See you later,</p>
<p dir="auto">Best regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/33251</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/33251</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Sat, 30 Jun 2018 03:00:00 GMT</pubDate></item><item><title><![CDATA[Reply to Sorting multiple chunks of non-connected text on Fri, 29 Jun 2018 17:11:55 GMT]]></title><description><![CDATA[<p dir="auto">Hmm, in my experiments (with a hyphen separator), it did keep the indenting, I thought.  Maybe I’m wrong.</p>
<p dir="auto">This does the sorting that I think you wanted, but with the underscore separators, and I have confirmed indentation stayed consistent:</p>
<ol>
<li><strong>Find</strong> <code>([^_])\r\n</code> <strong>Replace</strong> <code>\1☺</code>  (this assumes windows CRLF line endings: the generic <code>\R</code> matched too much)</li>
<li>Sort</li>
<li><strong>Find</strong> <code>\1☺</code> <strong>Replace</strong> <code>\r\n</code></li>
</ol>
<p dir="auto">So</p>
<pre><code>Name: jkl1
Comment: name
Member of groups:
    TRAVEL_R
    STRAVEL_R
    PDOC_R
_______________________________________________________________________________
Name: abc3
Comment: name
Member of groups:
    SPURCHASE_R
    VOUCHER_R
    SVOUCHER_R
_______________________________________________________________________________
Name: xyz9
Comment: name
Member of groups:
    RDOC_R
    SRECEIVE_R
    CONTRACT_R
_______________________________________________________________________________
Name: abc1
Comment: name
Member of groups:
    TRAVEL_R
    VOUCHER_R
    SVOUCHER_R
_______________________________________________________________________________
</code></pre>
<p dir="auto">became</p>
<pre><code>Name: abc1
Comment: name
Member of groups:
    TRAVEL_R
    VOUCHER_R
    SVOUCHER_R
_______________________________________________________________________________
Name: abc3
Comment: name
Member of groups:
    SPURCHASE_R
    VOUCHER_R
    SVOUCHER_R
_______________________________________________________________________________
Name: jkl1
Comment: name
Member of groups:
    TRAVEL_R
    STRAVEL_R
    PDOC_R
_______________________________________________________________________________
Name: xyz9
Comment: name
Member of groups:
    RDOC_R
    SRECEIVE_R
    CONTRACT_R
_______________________________________________________________________________
</code></pre>
<p dir="auto">… but now I’m confused: Do you want to alphabetize by name? Or do you want to leave the records all in the same order, and just sort the group names within an individual record?  Or do you want both (ie, records going alphabetical by name, followed by groups going alphabetical inside it’s “member of groups” section)?</p>
<p dir="auto">If what I’ve shown doesn’t give what you want, then show at least two records (sets of lines) with at least two groups listed in each record, and show a before and after scenario.  (And make sure you include any exceptions or edge cases you think might crop up)</p>
<p dir="auto">That said, if you want to alphabetize only the group lines within a record, or something more complicated, I will reiterate: “if it gets more complicated than just simply sortin by name, I think it would be worth it to pick some scripting language…”.  Of course, <a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a> can probably work his magic on even something more complicated, but you’ll have to give a sufficient example to include all edge cases.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/33242</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/33242</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Fri, 29 Jun 2018 17:11:55 GMT</pubDate></item><item><title><![CDATA[Reply to Sorting multiple chunks of non-connected text on Fri, 29 Jun 2018 15:12:27 GMT]]></title><description><![CDATA[<p dir="auto">Thank you Peter. :)</p>
<p dir="auto">It was actually 80 underscores, not dashes. But I do see now that they show as a page break.<br />
Also, what didn’t show up, was that each of the items I wanted to sort had 5 spaces in from of them:</p>
<pre><code>Name: jkl1
Comment: name
Member of groups:
    TRAVEL_R
    STRAVEL_R
    PDOC_R
    SPURCHASE_R
    VOUCHER_R
    SVOUCHER_R
    RDOC_R
    SRECEIVE_R
    CONTRACT_R
_______________________________________________________________________________
</code></pre>
<p dir="auto">The above suggestion caused all groups of the same name to move together and moved all the users.<br />
I apologize for not stating this better earlier: I was hoping to maintain each users own groups, but sorted alphabetically down a long list.<br />
Each “Name” groups needs to remain as:</p>
<pre><code>Name:
Comment:
Member Of Groups:
A
B
C
...
_______________________________________________________________________________
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/33238</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/33238</guid><dc:creator><![CDATA[Jeff Test]]></dc:creator><pubDate>Fri, 29 Jun 2018 15:12:27 GMT</pubDate></item><item><title><![CDATA[Reply to Sorting multiple chunks of non-connected text on Wed, 27 Jun 2018 13:40:16 GMT]]></title><description><![CDATA[<p dir="auto">I would do it in a three-step process:</p>
<ol>
<li>
<p dir="auto">Search and replace (with</p>
<ul>
<li>
<p dir="auto"><strong>Find What :</strong> <code>\R(?!^-)</code></p>
<ul>
<li>find all the end-of-lines that are not followed by a - at the beginning of the line (if you need to allow some non-divider hyphens to start a line, you can put how ever many hyphens you showed: it got rendered as a horizontal-rule in the forum, so I cannot tell exactly how many hyphens you had on each divider line)</li>
</ul>
</li>
<li>
<p dir="auto"><strong>Replace with :</strong> <code>☺</code></p>
<ul>
<li>pick some character that doesn’t occur elsewhere in your document.  You might want to pick a unicode character that’s not likely to occur in your text (I picked the smiley <code>☺</code>), just to avoid collisions with common ASCII characters.</li>
</ul>
</li>
<li>
<p dir="auto"><strong>Replace All</strong></p>
</li>
</ul>
</li>
<li>
<p dir="auto"><code>Edit &gt; Line Operations &gt; Sort Lines Lexicographically Ascending</code></p>
</li>
<li>
<p dir="auto">Search and replace</p>
<ul>
<li>
<p dir="auto"><strong>Find What :</strong> <code>☺</code></p>
</li>
<li>
<p dir="auto"><strong>Replace With :</strong> <code>\r\n</code></p>
</li>
<li>
<p dir="auto"><strong>Replace All</strong></p>
</li>
</ul>
</li>
</ol>
<p dir="auto">If you wanted to sort by something <em>other</em> than name, you’ll have to do some fancier manipulation in the original search-and-replace to easily sort it inside Notepad++.  In theory, you could also use the <a href="http://sourceforge.net/projects/npppythonscript/files/Python%20Script%201.0.8.0/PythonScript_1.0.8.0.msi/download" rel="nofollow ugc">PythonScript plugin</a> to do more manipulation.</p>
<p dir="auto">Personally, if it gets more complicated than just sorting simply by name, I think it would be worth it to pick some scripting language that you’re familiar with (Perl is my go-to for text manipulation, but nowadays, more people know Python than Perl – and, as I mentioned, there is a PythonScript plugin that will allow you to keep things “inside” Notepad++): then you could parse the document into a meaningful structure, and then deal with the structured data, to sort with or rearrange, as you please.</p>
<p dir="auto">Or, if you don’t want to learn another language, you might do a search-and-replace to get it into an official CSV (being careful of lines commas,  and merging all the members of the groups with a different delimiter than you use between fields), then open it with your favorite spreadsheet or database, and sort on the appropriate column(s).</p>
<p dir="auto">For details on regular expressions, <a href="https://notepad-plus-plus.org/community/topic/15765/faq-desk-where-to-find-regex-documentation" rel="nofollow ugc">this FAQ Desk entry</a> points you to plenty of good sites for reference material.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/33199</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/33199</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Wed, 27 Jun 2018 13:40:16 GMT</pubDate></item></channel></rss>