Why not just do it directly (avoid the function call) ...
function sortIPList2 pIPList
set the itemdelimiter to "."
try
sort lines of pIPList ascending numeric \
by (item 1 of each * 16777216) + \
(item 2 of each *65536) + \
(item 3 of each *256) + \
(item 4 of each )
catch theError
breakpoint
end try
return pIPList
end sortIPList2
or if you prefer ...
by item 4 of each + 256 * ( item 3 of each + 256 * (item 2 of each + 256 *
item 1 of each ))
...
Alex.
On 30/06/2018 00:41, hh via use-livecode wrote:
Your IP addresses [0-255].[0-255].[0-255].[0-255]
are the hex IP numbers converted to base 256.
So you may try the following sorting function that
converts the IPs from base 256 to base 10 (decimal).
function ip2dec x
set itemdel to "."
repeat with i=0 to 3
add (item 4-i of x)*256^i to y
end repeat
return y
end ip2dec
on mouseUp
put fld "ips" into s
sort s numeric by ip2dec(each) # <----
put s into fld "out"
end mouseUp
_______________________________________________
use-livecode mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
_______________________________________________
use-livecode mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode