<?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[Can I sort IP addresses in numeric value]]></title><description><![CDATA[<p dir="auto">Hello,</p>
<p dir="auto">I have a problem, I need to find a way to sort ip addresses in the following format:</p>
<p dir="auto">192.168.1.1<br />
192.168.1.2<br />
192.168.2.12<br />
192.168.2.34<br />
192.168.3.4</p>
<p dir="auto">This is just a small example I am moving the data into notepad ++ in a jumbled format i.e</p>
<p dir="auto">192.168.2.3<br />
172.10.10.3<br />
192.168.1.56</p>
<p dir="auto">Has anyone come across this problem and can help please?</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/14354/can-i-sort-ip-addresses-in-numeric-value</link><generator>RSS for Node</generator><lastBuildDate>Wed, 15 Apr 2026 17:40:44 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/14354.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 23 Aug 2017 15:21:55 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Can I sort IP addresses in numeric value on Thu, 11 Jan 2024 16:27:04 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> Edit &gt; Line Operations &gt; Sort Lines As Integers Ascending 😉</p>
<p dir="auto">Oh wow, necro thread 💀</p>
]]></description><link>https://community.notepad-plus-plus.org/post/91924</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/91924</guid><dc:creator><![CDATA[supasillyass]]></dc:creator><pubDate>Thu, 11 Jan 2024 16:27:04 GMT</pubDate></item><item><title><![CDATA[Reply to Can I sort IP addresses in numeric value on Thu, 11 Jan 2024 13:12:43 GMT]]></title><description><![CDATA[<p dir="auto">I spoke before of:</p>
<blockquote>
<p dir="auto">perhaps quietly, corrupt a user’s file</p>
</blockquote>
<p dir="auto">and then I presented some code which does just that.  :-(</p>
<hr />
<p dir="auto">Instead of:</p>
<p dir="auto"><code>eol = ['\r\n', '\n', '\r'][editor.getEOLMode()]</code></p>
<p dir="auto">in my posting immediately above, it should have been:</p>
<p dir="auto"><code>eol = ['\r\n', '\r', '\n'][editor.getEOLMode()]</code></p>
<p dir="auto">(note that the <code>'\r'</code> and the <code>'\n'</code> were swapped in the erroneous code)</p>
<p dir="auto">My apologies for the error.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/91918</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/91918</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Thu, 11 Jan 2024 13:12:43 GMT</pubDate></item><item><title><![CDATA[Reply to Can I sort IP addresses in numeric value on Fri, 06 Oct 2023 17:07:24 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></p>
<p dir="auto">My version of that is <code>eol = ['\r\n', '\n', '\r'][editor.getEOLMode()]</code>… the same, but all in one place.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/89722</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/89722</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Fri, 06 Oct 2023 17:07:24 GMT</pubDate></item><item><title><![CDATA[Reply to Can I sort IP addresses in numeric value on Fri, 06 Oct 2023 16:33:18 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 in <a href="/post/89715">Can I sort IP addresses in numeric value</a>:</p>
<blockquote>
<p dir="auto">corrupt a user’s file, because it changes line endings from Windows’ type (CRLF) to Linux type (LF).</p>
</blockquote>
<p dir="auto">AlanKilborn is correct.</p>
<p dir="auto">My practice in any file when I’m dumping lines is to do something like this:</p>
<pre><code class="language-py"># Near the top of the script (with other global constants)
EOLS = ('\r\n', '\r', '\n')
# code
#...
# whenever I want to choose newline, do this:
    eol = EOLS[editor.getEOLMode()]
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/89718</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/89718</guid><dc:creator><![CDATA[Mark Olson]]></dc:creator><pubDate>Fri, 06 Oct 2023 16:33:18 GMT</pubDate></item><item><title><![CDATA[Reply to Can I sort IP addresses in numeric value on Fri, 06 Oct 2023 11:31:02 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/29474">@Jon</a></p>
<p dir="auto">This script will, perhaps quietly, corrupt a user’s file, because it changes line endings from Windows’ type (CRLF) to Linux type (LF).  :-(</p>
]]></description><link>https://community.notepad-plus-plus.org/post/89715</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/89715</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Fri, 06 Oct 2023 11:31:02 GMT</pubDate></item><item><title><![CDATA[Reply to Can I sort IP addresses in numeric value on Fri, 06 Oct 2023 03:48:48 GMT]]></title><description><![CDATA[<p dir="auto">The Python solution hasn’t been discussed here and as that thread is very old I’ll post here.<br />
… I need 1 reputation point to post links, so here it is - remove the spaces!<br />
https:// community.notepad-plus-plus .org/topic/11105/feature-request-sort-by-ip-address-cidr-notation</p>
<p dir="auto">Those scripts didn’t work for me so I wrote my own. This handles both IP &amp; CIDR interchangeably.</p>
<pre><code>import re

addresses = editor.getText().split('\n') # Contents to string array
 
non_blank_addresses = [] # Filter out blank lines
for addr in addresses:   #  and clean the input data using regular expressions.
  cleaned_addr = re.sub(r'\s', '', addr)  # Remove whitespace
  if cleaned_addr:       # Check if not empty
    non_blank_addresses.append(cleaned_addr)

# Sort all addresses (CIDRs and individual IPs)
sorted_addresses = sorted(non_blank_addresses, key=lambda addr: (
  tuple(map(int, re.split(r'[/.]', addr)))[:-1],  # Extract IP components
  int(re.split(r'[/.]', addr)[-1]) if '/' in addr else 32  # Extract and convert prefix length
))

editor.beginUndoAction()
editor.setText('\n'.join(sorted_addresses))
editor.endUndoAction()
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/89714</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/89714</guid><dc:creator><![CDATA[Jon]]></dc:creator><pubDate>Fri, 06 Oct 2023 03:48:48 GMT</pubDate></item><item><title><![CDATA[Reply to Can I sort IP addresses in numeric value on Sat, 19 Aug 2023 15:23:45 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/29120">@michalpl7</a> said in <a href="/post/88707">Can I sort IP addresses in numeric value</a>:</p>
<blockquote>
<p dir="auto">it also could change MAC address deletes “00” from it</p>
</blockquote>
<p dir="auto">I was afraid you were going to realize that exception.</p>
<p dir="auto"><code>(?:^|\.)\K0+(?=\d+?(?=\.|\h))</code></p>
<p dir="auto">This changes the requirement to whatever goes before the leading zero digits must be either start of line or a period.  But because of the <code>\K</code>, you have to use <strong>Replace All</strong> (it will not work with a single <strong>Replace</strong>)</p>
<p dir="auto">When I tried my old one on</p>
<pre><code>192.168.001.020 d067-bc22-0004
</code></pre>
<p dir="auto">it wrongly became</p>
<pre><code>192.168.1.20 d067-bc22-4
</code></pre>
<p dir="auto">but when I tried my modified expression, it correctly became</p>
<pre><code>192.168.1.20 d067-bc22-0004
</code></pre>
<p dir="auto">But if <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/27184">@Coises</a>’s plugin solution works for you, I’d go that way, because it doesn’t involve as much complication, and ensures that it’s only dealing with the digits inside an IP address.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/88728</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/88728</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Sat, 19 Aug 2023 15:23:45 GMT</pubDate></item><item><title><![CDATA[Reply to Can I sort IP addresses in numeric value on Sat, 19 Aug 2023 11:45:00 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/27184">@Coises</a> said in <a href="/post/88694">Can I sort IP addresses in numeric value</a>:</p>
<blockquote>
<p dir="auto">1,2,3,4</p>
</blockquote>
<p dir="auto">Perfect! Thanks :)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/88712</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/88712</guid><dc:creator><![CDATA[michalpl7]]></dc:creator><pubDate>Sat, 19 Aug 2023 11:45:00 GMT</pubDate></item><item><title><![CDATA[Reply to Can I sort IP addresses in numeric value on Sat, 19 Aug 2023 08:11:41 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/3841">@PeterJones</a> hello the problem with this command is that it also could change MAC address deletes “00” from it.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/88707</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/88707</guid><dc:creator><![CDATA[michalpl7]]></dc:creator><pubDate>Sat, 19 Aug 2023 08:11:41 GMT</pubDate></item><item><title><![CDATA[Reply to Can I sort IP addresses in numeric value on Fri, 18 Aug 2023 18:51:19 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/29120">@michalpl7</a> said in <a href="/post/88692">Can I sort IP addresses in numeric value</a>:</p>
<blockquote>
<p dir="auto">Hello is there any option to sort ip addresses if they followed by other data in columns? This method is not working. For example:</p>
<p dir="auto">IP                        MAC<br />
192.168.1.140     0023-ac20-3918<br />
192.168.1.49       08ea-2931-ca12<br />
192.168.1.145     08ea-2903-bc32<br />
192.168.1.133     98f1-12ca-2456<br />
192.168.1.73       9440-21ab-2512<br />
192.168.1.134     eceb-565a-2953<br />
192.168.1.132     d067-bc22-3174</p>
</blockquote>
<p dir="auto">In addition to Peter Jones’ solution, you can also do this in a single operation with the <a href="https://github.com/Coises/ColumnsPlusPlus/releases/tag/v0.6.1-alpha" rel="nofollow ugc">Columns++</a> plugin.</p>
<p dir="auto">Select the lines you want to sort.</p>
<p dir="auto">Select <strong>Sort…</strong> from the <strong>Columns++</strong> menu.</p>
<p dir="auto"><img src="/assets/uploads/files/1692384595469-columns-sort-for-ip-addresses.png" alt="Columns++ Sort for IP addresses.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Select:<br />
<strong>What to sort</strong>: <strong>Whole lines</strong><br />
<strong>Sort type</strong>: <strong>Ascending</strong> and <strong>Numeric</strong><img src="undefined" alt="undefined" class=" img-fluid img-markdown" /><br />
<strong>Sort key</strong>: <strong>Regular expression</strong></p>
<p dir="auto">Check: <strong>Specify keys using capture groups</strong>.</p>
<p dir="auto">Enter:<br />
<strong>Find what:</strong>  <code>(\d+)\.(\d+)\.(\d+)\.(\d+)</code><br />
<strong>Keys:</strong> <code>1,2,3,4</code></p>
<p dir="auto">Click OK.</p>
<p dir="auto">When asked to “Convert to a rectangular selection enclosing the selected lines?” click OK.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/88694</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/88694</guid><dc:creator><![CDATA[Coises]]></dc:creator><pubDate>Fri, 18 Aug 2023 18:51:19 GMT</pubDate></item><item><title><![CDATA[Reply to Can I sort IP addresses in numeric value on Fri, 18 Aug 2023 17:27:47 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/29120">@michalpl7</a> said in <a href="/post/88692">Can I sort IP addresses in numeric value</a>:</p>
<blockquote>
<p dir="auto">Hello is there any option to sort ip addresses if they followed by other data in columns</p>
</blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a>’s regex above assumed the whole line was an IP.</p>
<p dir="auto">But with a slight tweak – allowing a space or tab to come after the final digits, not just a dot or newline – makes it match any of your examples.  So his first FIND WHAT becomes <code>(?:^|(?&lt;=\.))\d(\d)?(?=\.|\h|$)</code></p>
<p dir="auto">His first replacement (with spaces) works… but it’s harder to undo later when you have other spaces in the rest of your line.  So I change his first REPLACE WITH to <code>0(?1:0)$0</code> so that it inserts one or two zeroes instead of one or two spaces</p>
<p dir="auto">So<br />
FIND = <code>(?:^|(?&lt;=\.))\d(\d)?(?=\.|\h|$)</code><br />
REPLACE = <code>0(?1:0)$0</code><br />
SEARCH MODE = regular expression</p>
<p dir="auto">That search/replace will give you</p>
<pre><code>192.168.001.140 0023-ac20-3918
192.168.001.049 08ea-2931-ca12
192.168.001.145 08ea-2903-bc32
192.168.001.133 98f1-12ca-2456
192.168.001.073 9440-21ab-2512
192.168.001.134 eceb-565a-2953
192.168.001.132 d067-bc22-3174
</code></pre>
<p dir="auto">Now you can sort lexicographically ascending as he recommended.</p>
<p dir="auto">Then you need to change the second search/replace.  Instead of searching for spaces and removing them, what we want to do is search for leading zeroes and remove them.</p>
<p dir="auto">FIND = <code>\b0+(?=\d+?(?=\.|\h))</code><br />
REPLACE = leave empty<br />
SEARCH MODE = regular expression</p>
<p dir="auto">This got me to</p>
<pre><code>192.168.1.49 08ea-2931-ca12
192.168.1.73 9440-21ab-2512
192.168.1.132 d067-bc22-3174
192.168.1.133 98f1-12ca-2456
192.168.1.134 eceb-565a-2953
192.168.1.140 0023-ac20-3918
192.168.1.145 08ea-2903-bc32
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/88693</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/88693</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Fri, 18 Aug 2023 17:27:47 GMT</pubDate></item><item><title><![CDATA[Reply to Can I sort IP addresses in numeric value on Fri, 18 Aug 2023 17:10:33 GMT]]></title><description><![CDATA[<p dir="auto">Hello is there any option to sort ip addresses if they followed by other data in columns? This method is not working. For example:</p>
<p dir="auto">IP                        MAC<br />
192.168.1.140     0023-ac20-3918<br />
192.168.1.49       08ea-2931-ca12<br />
192.168.1.145     08ea-2903-bc32<br />
192.168.1.133     98f1-12ca-2456<br />
192.168.1.73       9440-21ab-2512<br />
192.168.1.134     eceb-565a-2953<br />
192.168.1.132     d067-bc22-3174</p>
]]></description><link>https://community.notepad-plus-plus.org/post/88692</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/88692</guid><dc:creator><![CDATA[michalpl7]]></dc:creator><pubDate>Fri, 18 Aug 2023 17:10:33 GMT</pubDate></item><item><title><![CDATA[Reply to Can I sort IP addresses in numeric value on Mon, 26 Nov 2018 13:00:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/13762">@Matthijs-Wensveen</a> said:</p>
<blockquote>
<p dir="auto">I replaced the comma’s in a comma-separated list of IP addresses with ‘\n’ in a CRLF (Windows) document</p>
</blockquote>
<p dir="auto">For the benefit of any future readers, what you should have done is a regular-expression replacement with <code>\r\n</code> for a Windows document.</p>
<blockquote>
<p dir="auto">Sorting as described above produced unpredictable (to me) results.</p>
</blockquote>
<p dir="auto">What does this mean? You also said “Works great”–so which is it?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/36791</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/36791</guid><dc:creator><![CDATA[Scott Sumner]]></dc:creator><pubDate>Mon, 26 Nov 2018 13:00:53 GMT</pubDate></item><item><title><![CDATA[Reply to Can I sort IP addresses in numeric value on Mon, 26 Nov 2018 12:06:22 GMT]]></title><description><![CDATA[<p dir="auto">Works great. Tiny addition: make sure you have the correct EOL. I replaced the comma’s in a comma-separated list of IP addresses with ‘\n’ in a CRLF (Windows) document. Sorting as described above produced unpredictable (to me) results.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/36790</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/36790</guid><dc:creator><![CDATA[Matthijs Wensveen]]></dc:creator><pubDate>Mon, 26 Nov 2018 12:06:22 GMT</pubDate></item><item><title><![CDATA[Reply to Can I sort IP addresses in numeric value on Tue, 29 Aug 2017 08:43:50 GMT]]></title><description><![CDATA[<p dir="auto">Many Thanks this works great!!!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/26501</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/26501</guid><dc:creator><![CDATA[Mark Brookman]]></dc:creator><pubDate>Tue, 29 Aug 2017 08:43:50 GMT</pubDate></item><item><title><![CDATA[Reply to Can I sort IP addresses in numeric value on Fri, 25 Aug 2017 13:14:28 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Thankyou for the post, I have a task for this soon and will give you an update.</p>
<p dir="auto">Many Thanks</p>
<p dir="auto">Mark</p>
]]></description><link>https://community.notepad-plus-plus.org/post/26448</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/26448</guid><dc:creator><![CDATA[Mark Brookman]]></dc:creator><pubDate>Fri, 25 Aug 2017 13:14:28 GMT</pubDate></item><item><title><![CDATA[Reply to Can I sort IP addresses in numeric value on Thu, 24 Aug 2017 20:20:14 GMT]]></title><description><![CDATA[<p dir="auto">Great post and detailed explanation.</p>
<p dir="auto">The following is a solution to a scenario when migrating DHCP reserved MAC addresses. When exporting via command line on server, the subsection regarding reserved IP is not sorted. In efforts to clean-up this list prior to migration, sorting is a great solution.</p>
<p dir="auto">Exporting DHCP data from Windows Server via command line as explained here:<br />
<a href="https://support.microsoft.com/en-us/help/325473/how-to-move-a-dhcp-database-from-a-computer-that-is-running-windows-nt" rel="nofollow ugc">https://support.microsoft.com/en-us/help/325473/how-to-move-a-dhcp-database-from-a-computer-that-is-running-windows-nt</a></p>
<p dir="auto">Export:</p>
<pre><code class="language-sh">netsh dhcp server dump &gt; C:\dhcp.txt
</code></pre>
<p dir="auto">Import:</p>
<pre><code class="language-sh">netsh exec c:\dhcp.txt
</code></pre>
<p dir="auto">Within the section “Add ReservedIp to the Scope” each line is dumped like (MacAddress is actual):</p>
<pre><code class="language-sh">Dhcp Server \\domain.name.local Scope 192.168.10.0 Add reservedip 192.168.10.125 MacAddress "DeviceName" "DeviceName" "BOTH"
</code></pre>
<p dir="auto">Leveraging details from a similar post (below) I was able to adapt a version for my specific needs:<br />
<a href="https://notepad-plus-plus.org/community/topic/11105/feature-request-sort-by-ip-address-cidr-notation" rel="nofollow ugc">https://notepad-plus-plus.org/community/topic/11105/feature-request-sort-by-ip-address-cidr-notation</a></p>
<p dir="auto">Enter <strong><code>(?:^|(?&lt;=\.))\d(\d)?(?=\.|$|\s)</code></strong>, in the Find what: zone<br />
Enter <strong><code>\x23(?1:\x23)$0</code></strong>, in the Replace with: zone</p>
<p dir="auto">Note: The addition of the pipe, forward-slash, s (match trailing space)<br />
(I chose ASCII hex 23 (dec 35) number sign as a temporary char place holder not shown in the DHCP server naming. Experiment to see which char works for your needs.)<br />
<a href="http://www.ascii.cl/htmlcodes.htm" rel="nofollow ugc">http://www.ascii.cl/htmlcodes.htm</a></p>
<p dir="auto">The end result is proper spacing (padded with “hashes”).</p>
<p dir="auto">Then sort via “Sort Lines Lexicographically Ascending”<br />
<a href="https://superuser.com/questions/762279/sorting-lines-in-notepad-without-the-textfx-plugin#762281" rel="nofollow ugc">https://superuser.com/questions/762279/sorting-lines-in-notepad-without-the-textfx-plugin#762281</a></p>
<p dir="auto">Now “unpad” the IP address for later import:<br />
SEARCH <strong><code>\x23</code></strong><br />
REPLACE <strong><code>Leave EMPTY</code></strong></p>
<p dir="auto">Hope this helps.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/26434</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/26434</guid><dc:creator><![CDATA[Gabriel Cunningham]]></dc:creator><pubDate>Thu, 24 Aug 2017 20:20:14 GMT</pubDate></item><item><title><![CDATA[Reply to Can I sort IP addresses in numeric value on Thu, 24 Aug 2017 20:30:45 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/9594">@mark-brookman</a>,</p>
<p dir="auto"><strong>Not</strong> very difficult, indeed ! We just have to re-write each <strong>IPV4</strong> address, in such a way that it <strong>only</strong> needs a classical <strong>sort</strong> ;-)</p>
<p dir="auto">So, starting, for instance, with that list of <strong>IPV4</strong> addresses, below :</p>
<pre><code class="language-diff">192.168.5.13
192.168.5.9
192.168.5.205
192.205.54.3
92.168.5.3
9.168.5.3
192.168.210.3
192.168.17.107
192.168.17.3
192.20.2.3
192.205.7.3
12.120.255.0
192.168.210.127
192.168.210.29
1.1.12.127
0.0.0.0
255.255.255.255
</code></pre>
<p dir="auto">Now :</p>
<ul>
<li>
<p dir="auto">Move back to the <strong>beginning</strong> of your list</p>
</li>
<li>
<p dir="auto">Open the <strong>Replace</strong> dialog</p>
</li>
<li>
<p dir="auto">Enter <strong><code>(?:^|(?&lt;=\.))\d(\d)?(?=\.|$)</code></strong>, in the <strong>Find what:</strong> zone</p>
</li>
<li>
<p dir="auto">Enter <strong><code>\x20(?1:\x20)$0</code></strong>, in the <strong>Replace with:</strong> zone</p>
</li>
<li>
<p dir="auto">Select the <strong>Regular expression</strong> search mode</p>
</li>
<li>
<p dir="auto">Click on the <strong>Replace All</strong> button</p>
</li>
</ul>
<p dir="auto">You should obtain the <strong>modified</strong> list, below :</p>
<pre><code class="language-diff">192.168.  5. 13
192.168.  5.  9
192.168.  5.205
192.205. 54.  3
 92.168.  5.  3
  9.168.  5.  3
192.168.210.  3
192.168. 17.107
192.168. 17.  3
192. 20.  2.  3
192.205.  7.  3
 12.120.255.  0
192.168.210.127
192.168.210. 29
  1.  1. 12.127
  0.  0.  0.  0
255.255.255.255
</code></pre>
<p dir="auto"><strong>Notes</strong> :</p>
<ul>
<li>
<p dir="auto">This <strong>S/R</strong> adds :</p>
<ul>
<li>
<p dir="auto"><strong>Two space</strong> characters to any individual <strong>one-digit</strong> number of an <strong>IPV4</strong> address</p>
</li>
<li>
<p dir="auto"><strong>One space</strong> character to any individual <strong>two-digits</strong> number of an <strong>IPV4</strong> address</p>
</li>
</ul>
</li>
<li>
<p dir="auto">The string searched is the part <strong><code>\d(\d)?</code></strong> of the <strong>search</strong> regex, that is to say an individual <strong>one</strong> or <strong>two digits</strong> number. Note that in case of a <strong>one-digit</strong> number, the <strong>optional</strong> group <strong><code>(\d)</code></strong> does <strong>not</strong> exist</p>
</li>
<li>
<p dir="auto">An <strong>overall</strong> match will occur, ONLY IF it is, <strong>both</strong> :</p>
<ul>
<li>
<p dir="auto">Preceded by a <strong>beginning</strong> of line or a <strong><code>dot</code></strong> symbol ( <strong><code>(?:^|(?&lt;=\.))</code></strong> ) Note the <strong>non-capturing</strong> group <strong><code>(?:......)</code></strong></p>
</li>
<li>
<p dir="auto">Followed by a <strong><code>dot</code></strong> symbol or an <strong>end</strong> of line, ( <strong><code>(?=\.|$)</code></strong> )</p>
</li>
</ul>
</li>
<li>
<p dir="auto">In <strong>replacement</strong> , we rewrite :</p>
</li>
<li>
<p dir="auto">A first <strong>space</strong> character ( <strong><code>\x20</code></strong> )</p>
</li>
<li>
<p dir="auto">A second <strong>space</strong> character, only if <strong>group 1</strong> does <strong>not</strong> exist ( <strong><code>(?1:\x20)</code></strong> , with the ELSE part, after the <strong>colon</strong> <strong><code>\x20</code></strong> )</p>
</li>
<li>
<p dir="auto">Finally, the <strong>entire</strong> searched string ( <strong><code>$0</code></strong> ), which is a <strong>one</strong> or <strong>two</strong> digit(s) <strong>individual</strong> number</p>
</li>
</ul>
<hr />
<p dir="auto">Now, <strong>sort</strong> this list with the option <strong>Edit &gt; Line Operations &gt; Sort lines Lexicographically Ascending</strong>. You obtain :</p>
<pre><code class="language-diff">  0.  0.  0.  0
  1.  1. 12.127
  9.168.  5.  3
 12.120.255.  0
 92.168.  5.  3
192. 20.  2.  3
192.168.  5.  9
192.168.  5. 13
192.168.  5.205
192.168. 17.  3
192.168. 17.107
192.168.210.  3
192.168.210. 29
192.168.210.127
192.205.  7.  3
192.205. 54.  3
255.255.255.255
</code></pre>
<p dir="auto">Finally, just get <strong>rid of</strong> all <strong>space</strong> characters, with the simple <strong>regex</strong> S/R, below :</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">Et voilà !</p>
<p dir="auto">Here is your list of <strong>IPV4</strong> adresses, sorted in a <strong>numeric</strong> way :-))</p>
<pre><code class="language-diff">0.0.0.0
1.1.12.127
9.168.5.3
12.120.255.0
92.168.5.3
192.20.2.3
192.168.5.9
192.168.5.13
192.168.5.205
192.168.17.3
192.168.17.107
192.168.210.3
192.168.210.29
192.168.210.127
192.205.7.3
192.205.54.3
255.255.255.255
</code></pre>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/26429</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/26429</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Thu, 24 Aug 2017 20:30:45 GMT</pubDate></item></channel></rss>