Re: Sort IP List

2018-07-02 Thread Tom Glod via use-livecode
ok i will try to provide more info on this from my stack when it happens
next.

On Mon, Jul 2, 2018 at 12:17 PM, J. Landman Gay via use-livecode <
use-livecode@lists.runrev.com> wrote:

> There used to be a barrage of pending messages generated by the IDE that
> were updating in the message box. Look at the messages pane and set it to
> auto-update, see if they're still there
>
> --
> Jacqueline Landman Gay | jac...@hyperactivesw.com
> HyperActive Software | http://www.hyperactivesw.com
>
> On July 2, 2018 9:58:40 AM Mark Wieder via use-livecode <
> use-livecode@lists.runrev.com> wrote:
>
> On 07/02/2018 06:59 AM, Tom Glod via use-livecode wrote:
>>
>>> oh yes. message box makes LC slow to a crawl..I've noticed that. i
>>> can
>>> confirm that. Win 10 LC 9 too.
>>>
>>
>> I've seen that too, especially when spewing debugging statements to the
>> messagebox. But not all the time, and nothing I can get a recipe for.
>>
>> --
>>  Mark Wieder
>>  ahsoftw...@gmail.com
>>
>> ___
>> use-livecode mailing list
>> use-livecode@lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>
>
>
>
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Sort IP List

2018-07-02 Thread J. Landman Gay via use-livecode
There used to be a barrage of pending messages generated by the IDE that 
were updating in the message box. Look at the messages pane and set it to 
auto-update, see if they're still there


--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
On July 2, 2018 9:58:40 AM Mark Wieder via use-livecode 
 wrote:



On 07/02/2018 06:59 AM, Tom Glod via use-livecode wrote:

oh yes. message box makes LC slow to a crawl..I've noticed that. i can
confirm that. Win 10 LC 9 too.


I've seen that too, especially when spewing debugging statements to the
messagebox. But not all the time, and nothing I can get a recipe for.

--
 Mark Wieder
 ahsoftw...@gmail.com

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your 
subscription preferences:

http://lists.runrev.com/mailman/listinfo/use-livecode





___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Sort IP List

2018-07-02 Thread Mark Wieder via use-livecode

On 07/02/2018 06:59 AM, Tom Glod via use-livecode wrote:

oh yes. message box makes LC slow to a crawl..I've noticed that. i can
confirm that. Win 10 LC 9 too.


I've seen that too, especially when spewing debugging statements to the 
messagebox. But not all the time, and nothing I can get a recipe for.


--
 Mark Wieder
 ahsoftw...@gmail.com

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Sort IP List

2018-07-02 Thread Tom Glod via use-livecode
oh yes. message box makes LC slow to a crawl..I've noticed that. i can
confirm that. Win 10 LC 9 too.

On Mon, Jul 2, 2018 at 12:45 AM, Ralph DiMola via use-livecode <
use-livecode@lists.runrev.com> wrote:

> I agree "mind-bogglingly nonsensical"
>
> Something is very odd. If I open the stack with fresh start of the IDE I
> start getting results closer to what I would expect. The by ref is about 5
> to 10% faster. NOW Every so often when I open the message box things
> start getting weird and I get those crazy results. If I close msg then it
> is
> different weird. When I say different I mean that another step in the
> process starts taking longer. Close LC and restart and things are back to
> normal until I open the message box a few times. No pattern as of yet. But
> I
> do know if you don't open the message box it never goes crazy. I'm going to
> dig in and see what's happening here. If I can get a recipe I'm going to
> send it off to Panos.
>
> Win 10 VM
> LC 9
>
> Ralph DiMola
> IT Director
> Evergreen Information Services
> rdim...@evergreeninfo.net
>
> -Original Message-
> From: use-livecode [mailto:use-livecode-boun...@lists.runrev.com] On
> Behalf
> Of Mark Wieder via use-livecode
> Sent: Saturday, June 30, 2018 11:05 PM
> To: Ralph DiMola via use-livecode
> Cc: Mark Wieder
> Subject: Re: Sort IP List
>
> Ralph-
>
> Not that I'm doubting your findings, but those both seem mind-bogglingly
> nonsensical to me. Can you post your test code?
>
> --
>   Mark Wieder
>   ahsoftw...@gmail.com
>
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


RE: Sort IP List

2018-07-01 Thread Ralph DiMola via use-livecode
I agree "mind-bogglingly nonsensical"

Something is very odd. If I open the stack with fresh start of the IDE I
start getting results closer to what I would expect. The by ref is about 5
to 10% faster. NOW Every so often when I open the message box things
start getting weird and I get those crazy results. If I close msg then it is
different weird. When I say different I mean that another step in the
process starts taking longer. Close LC and restart and things are back to
normal until I open the message box a few times. No pattern as of yet. But I
do know if you don't open the message box it never goes crazy. I'm going to
dig in and see what's happening here. If I can get a recipe I'm going to
send it off to Panos.

Win 10 VM
LC 9

Ralph DiMola
IT Director
Evergreen Information Services
rdim...@evergreeninfo.net

-Original Message-
From: use-livecode [mailto:use-livecode-boun...@lists.runrev.com] On Behalf
Of Mark Wieder via use-livecode
Sent: Saturday, June 30, 2018 11:05 PM
To: Ralph DiMola via use-livecode
Cc: Mark Wieder
Subject: Re: Sort IP List

Ralph-

Not that I'm doubting your findings, but those both seem mind-bogglingly
nonsensical to me. Can you post your test code?

--
  Mark Wieder
  ahsoftw...@gmail.com

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Sort IP List

2018-06-30 Thread Mark Wieder via use-livecode

Ralph-

Not that I'm doubting your findings, but those both seem mind-bogglingly 
nonsensical to me. Can you post your test code?


--
 Mark Wieder
 ahsoftw...@gmail.com

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


RE: Sort IP List

2018-06-30 Thread Ralph DiMola via use-livecode
How fortuitous... I am finding the bottlenecks in some code under a deadline
the last few days and found some interesting observations.

1) Assembling, putting data into a field and doing text editing (replace x
with y in fld F1) in an non-visible field object is faster than assembling a
line in a local var and then putting it into the field once. I understand
that I'm moving the data twice but I thought there was some overhead of
field formatting every time I changed the data. apparently not...

I had a function call in a loop with two params and it returned a text
string of a few hundred to a few thousand cars. I changed it to a handler
with three params all by ref(the third being the var that the function
version set. Now I would have though the with everything by ref it would be
faster but in fact it was slower by 50%.

LC makes it so easy to do timings. I actually had fun tracking down and
attacking each bottleneck. Some stuff like putting simple calculations
in-line repeat constructs speeded things up as expected, others befuddled
me.

Ralph DiMola
IT Director
Evergreen Information Services
rdim...@evergreeninfo.net

-Original Message-
From: use-livecode [mailto:use-livecode-boun...@lists.runrev.com] On Behalf
Of Tom Glod via use-livecode
Sent: Saturday, June 30, 2018 3:51 PM
To: How to use LiveCode
Cc: Tom Glod
Subject: Re: Sort IP List

good thread you guys...code optimization questswhat fun.

On Sat, Jun 30, 2018 at 2:01 PM, Niggemann, Bernd via use-livecode <
use-livecode@lists.runrev.com> wrote:

> Hermann,
>
> I did not see Alex's solution until after I posted. I agree that 
> inline is probably always faster.
>
> And after I saw Alex's post I would not have thought that one could do 
> it that way, thanks Alex. On top it is by far the fastest.
>
> On the other hand sort by myFunction(each) is so powerful that you can 
> do things that are probably not possible inline.
>
> Kind regards
> Bernd
>
>
>
>
> hh via use-livecode<https://www.mail-archive.com/search?l=use-
> livec...@lists.runrev.com=from:%22hh+via+use%5C-livecode%22> Sat, 30 
> Jun 2018 03:12:55 -0700<https://www.mail-archive.com/search?l=use-
> livec...@lists.runrev.com=date:20180630> wrote:
>
>
> @Bernd
> Depending on the function an inline computation (as Alex denoted) may 
> be even faster than the private function calls?
> Here, with IPv4 addresses, it is faster.
>
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your 
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Sort IP List

2018-06-30 Thread Tom Glod via use-livecode
good thread you guys...code optimization questswhat fun.

On Sat, Jun 30, 2018 at 2:01 PM, Niggemann, Bernd via use-livecode <
use-livecode@lists.runrev.com> wrote:

> Hermann,
>
> I did not see Alex's solution until after I posted. I agree that inline is
> probably always faster.
>
> And after I saw Alex's post I would not have thought that one could do it
> that way, thanks Alex. On top it is by far the fastest.
>
> On the other hand sort by myFunction(each) is so powerful that you can do
> things that are probably not possible inline.
>
> Kind regards
> Bernd
>
>
>
>
> hh via use-livecode livec...@lists.runrev.com=from:%22hh+via+use%5C-livecode%22> Sat, 30
> Jun 2018 03:12:55 -0700 livec...@lists.runrev.com=date:20180630> wrote:
>
>
> @Bernd
> Depending on the function an inline computation (as Alex denoted)
> may be even faster than the private function calls?
> Here, with IPv4 addresses, it is faster.
>
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Sort IP List

2018-06-30 Thread Niggemann, Bernd via use-livecode
Hermann,

I did not see Alex's solution until after I posted. I agree that inline is 
probably always faster.

And after I saw Alex's post I would not have thought that one could do it that 
way, thanks Alex. On top it is by far the fastest.

On the other hand sort by myFunction(each) is so powerful that you can do 
things that are probably not possible inline.

Kind regards
Bernd




hh via 
use-livecode
 Sat, 30 Jun 2018 03:12:55 
-0700
 wrote:


@Bernd
Depending on the function an inline computation (as Alex denoted)
may be even faster than the private function calls?
Here, with IPv4 addresses, it is faster.

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Sort IP List

2018-06-30 Thread Brian Milby via use-livecode
Here are some times on my system for comparison (10 random IPs):

216% - ip2dec: 463 ms
190% - ip2decpvt: 407 ms
171% - ip2dec2: 366 ms
147% - ip2dec2pvt: 314 ms
200% - sortIPList: 427 ms --> original from Bob
100% - sortIPList2: 215 ms --> Alex's inline with constants
152% - sortIPList3: 325 ms --> numtobyte(item 1) &...
107% - sortIPList4: 230 ms --> bitOr instead of +
100% - sortIPList5: 214 ms --> item 4 of each + 256 * (...

sortIPList2 comes out fastest most of the time.  sortIPList5 does come out
ahead on some runs (Alex's alternate code).  I did all of this because I
was curious how the speed of using numtobyte would impact things.  It is
comparable to using a private function (ip2dec2pvt), but still slower than
inline.  While there I decided to also test the bitOr.


On Sat, Jun 30, 2018 at 5:10 AM, hh via use-livecode <
use-livecode@lists.runrev.com> wrote:

> Remains to remark that the upcoming standard IPv6
> with its text representations
> (Section 2.2 of https://tools.ietf.org/html/rfc4291)
> will require more detailed methods,
> both for number base conversion and for item sorts/cosorts
> (the items are hex numbers ...)
>
> @Bernd
> Depending on the function an inline computation (as Alex denoted)
> may be even faster than the private function calls?
> Here, with IPv4 addresses, it is faster.
>
>
>
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Sort IP List

2018-06-30 Thread hh via use-livecode
Remains to remark that the upcoming standard IPv6
with its text representations
(Section 2.2 of https://tools.ietf.org/html/rfc4291)
will require more detailed methods,
both for number base conversion and for item sorts/cosorts
(the items are hex numbers ...)

@Bernd
Depending on the function an inline computation (as Alex denoted)
may be even faster than the private function calls?
Here, with IPv4 addresses, it is faster.



___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Sort IP List

2018-06-30 Thread Niggemann, Bernd via use-livecode
if you replace ip2dec with the same functionality as Hermann's (HH) function 
with

private function ip2dec2 x
   set the itemdel to "."
   return (item 4 of x) + (item 3 of x * 256) + (item 2 of x * 65536) + (item 1 
of x * 16777216)
end ip2dec2

then the special sort via function is faster than sorting the 4 items of the 
IPlist.

Note "private function" saves about 10 percent, overall Hermann's modified 
script saves about 20 percent compared to Bob's sort by item solution which was 
fastest up to now.

Tested 100.000 random IP addresses.

Kind regards
Bernd



hh via 
use-livecode
 Fri, 29 Jun 2018 16:43:38 
-0700
 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
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Sort IP List

2018-06-29 Thread Mike Bonner via use-livecode
You all are just too darn smart. great solution.

On Fri, Jun 29, 2018 at 5:54 PM Alex Tweedly via use-livecode <
use-livecode@lists.runrev.com> wrote:

> 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
> > use-livecode@lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
>
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Sort IP List

2018-06-29 Thread Bob Sneidar via use-livecode
Alex, you win the cookie! 4 ticks for 30,000 IP addresses! If we ever meet at a 
conference remind me and I will buy you beers. Not saying how namy, just more 
than one. :-)

Bob S


> On Jun 29, 2018, at 16:54 , Alex Tweedly via use-livecode 
>  wrote:
> 
> 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
>> use-livecode@lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription 
>> preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Sort IP List

2018-06-29 Thread Alex Tweedly via use-livecode

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
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Sort IP List

2018-06-29 Thread hh via use-livecode
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
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Sort IP List

2018-06-29 Thread Mike Bonner via use-livecode
Now that is weird because the sort is definitely working for me.OH
wait, you don't set the numberformat in your function.  Do you set it
elsewhere, and if so, does it stick when the function is called?  The sort
is definitely, no question, working for me.

I generate a list of IPs then in the msg box do this..

set the numberformat to "000"
set the itemdel to "."
put the millisec into tstart
sort lines of tList ascending numeric by (item 1 of each +0) & (item 2 of
each + 0) & (item 3 of each + 0) & (item 4 of each + 0)
put the millisec - tstart
put cr & tList after msg -- the list is sorted.

Not sure why it isn't working for you, but on the off chance its a version
difference, i'm on 9.0, community +, stable.

On Fri, Jun 29, 2018 at 4:33 PM Bob Sneidar via use-livecode <
use-livecode@lists.runrev.com> wrote:

> I have good news and bad news!
>
> function sortIPList2 pIPList
>set the itemdelimiter to "."
>try
>   sort lines of pIPList ascending numeric \
> by (item 1 of each + 0) & \
> (item 2 of each + 0) & \
> (item 3 of each + 0) & \
> (item 4 of each + 0)
>catch theError
>   breakpoint
>end try
>return pIPList
> end sortIPList2
>
> With a small subset of data, it doesn't error meaning I have some cruft in
> the data. Fair enough. The bad news is... IT DOESN'T SORT! LOL!!! Reversing
> the items does not help either.
>
> Bob S
>
> > On Jun 29, 2018, at 15:16 , Mike Bonner via use-livecode <
> use-livecode@lists.runrev.com> wrote:
> >
> > Yup, that would be it!
>
>
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Sort IP List

2018-06-29 Thread Bob Sneidar via use-livecode
I have good news and bad news! 

function sortIPList2 pIPList
   set the itemdelimiter to "."
   try
  sort lines of pIPList ascending numeric \
by (item 1 of each + 0) & \
(item 2 of each + 0) & \
(item 3 of each + 0) & \
(item 4 of each + 0)
   catch theError
  breakpoint
   end try
   return pIPList
end sortIPList2

With a small subset of data, it doesn't error meaning I have some cruft in the 
data. Fair enough. The bad news is... IT DOESN'T SORT! LOL!!! Reversing the 
items does not help either. 

Bob S

> On Jun 29, 2018, at 15:16 , Mike Bonner via use-livecode 
>  wrote:
> 
> Yup, that would be it!


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Sort IP List

2018-06-29 Thread Mike Bonner via use-livecode
Yup, that would be it!

On Fri, Jun 29, 2018 at 4:15 PM Bob Sneidar via use-livecode <
use-livecode@lists.runrev.com> wrote:

> Wait I know exactly what is wrong. I have a few lines that use CIDR
> notation ie. 192.168.1.0/24 and THAT is not a number!
>
> Bob S
>
>
> > On Jun 29, 2018, at 15:13 , Bob Sneidar via use-livecode <
> use-livecode@lists.runrev.com> wrote:
> >
> > Yeah mine won't run. I have:
> >
> > function sortIPList2 pIPList
> >   set the itemdelimiter to "."
> >   try
> >  sort lines of pIPList ascending numeric by (item 1 of each +0) &
> (item 2 of each + 0) & (item 3 of each + 0) & (item 4 of each + 0)
> >   catch theError
> >  breakpoint
> >   end try
> >   return pIPList
> > end sortIPList2
> >
> > Script hits breakpoint but there is nothing in theError. What version/OS
> are you running? We may have uncovered an engine anomaly.
> >
> > Bob S
> >
> >> On Jun 29, 2018, at 15:00 , Mike Bonner via use-livecode <
> use-livecode@lists.runrev.com> wrote:
> >>
> >> sort lines of tList ascending numeric by (item 1 of each +0) & (item 2
> of
> >> each + 0) & (item 3 of each + 0) & (item 4 of each + 0)
> >
> >
> > ___
> > use-livecode mailing list
> > use-livecode@lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
>
>
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Sort IP List

2018-06-29 Thread Bob Sneidar via use-livecode
Wait I know exactly what is wrong. I have a few lines that use CIDR notation 
ie. 192.168.1.0/24 and THAT is not a number!

Bob S


> On Jun 29, 2018, at 15:13 , Bob Sneidar via use-livecode 
>  wrote:
> 
> Yeah mine won't run. I have:
> 
> function sortIPList2 pIPList
>   set the itemdelimiter to "."
>   try
>  sort lines of pIPList ascending numeric by (item 1 of each +0) & (item 2 
> of each + 0) & (item 3 of each + 0) & (item 4 of each + 0)
>   catch theError
>  breakpoint
>   end try
>   return pIPList
> end sortIPList2
> 
> Script hits breakpoint but there is nothing in theError. What version/OS are 
> you running? We may have uncovered an engine anomaly. 
> 
> Bob S
> 
>> On Jun 29, 2018, at 15:00 , Mike Bonner via use-livecode 
>>  wrote:
>> 
>> sort lines of tList ascending numeric by (item 1 of each +0) & (item 2 of
>> each + 0) & (item 3 of each + 0) & (item 4 of each + 0)
> 
> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Sort IP List

2018-06-29 Thread Bob Sneidar via use-livecode
Yeah mine won't run. I have:

function sortIPList2 pIPList
   set the itemdelimiter to "."
   try
  sort lines of pIPList ascending numeric by (item 1 of each +0) & (item 2 
of each + 0) & (item 3 of each + 0) & (item 4 of each + 0)
   catch theError
  breakpoint
   end try
   return pIPList
end sortIPList2

Script hits breakpoint but there is nothing in theError. What version/OS are 
you running? We may have uncovered an engine anomaly. 

Bob S

> On Jun 29, 2018, at 15:00 , Mike Bonner via use-livecode 
>  wrote:
> 
> sort lines of tList ascending numeric by (item 1 of each +0) & (item 2 of
> each + 0) & (item 3 of each + 0) & (item 4 of each + 0)


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Sort IP List

2018-06-29 Thread Mike Bonner via use-livecode
Oh, the above assumes setting the numberformat to "000" as you specified of
course.

On Fri, Jun 29, 2018 at 4:00 PM Mike Bonner  wrote:

> Thx for the clue, I see what you mean.
>
> I had tried to get something similar to your value(item 1 of each +0)
> method to work and something wasn't clicking, but after seeing yours, I
> think I have it working.
>
> sort lines of tList ascending numeric by (item 1 of each +0) & (item 2 of
> each + 0) & (item 3 of each + 0) & (item 4 of each + 0)
>
> The above seems to work fine (and I avoided using value() to avoid an
> unnecessary function call), you just have to remember to set the
> itemdelimiter to "." otherwise you get the error.  This may be faster
> because there aren't a bunch of function calls like my first idea, though
> I'm not sure how overhead compares since the numbers must still be
> evaluated.
>
> Just did some testing and it seems to be way way faster.  100k lines sort
> in 3/4 of a second.
>
> On Fri, Jun 29, 2018 at 3:18 PM Bob Sneidar via use-livecode <
> use-livecode@lists.runrev.com> wrote:
>
>> Yeah, no I get runtime error. 
>>
>> > On Jun 29, 2018, at 14:09 , Bob Sneidar via use-livecode <
>> use-livecode@lists.runrev.com> wrote:
>> >
>> > Yes because your ampersand operator is not passing different
>> arguements, it's concatenating the items together so that 10.2.245.6
>> produces the integer 1022456. But 10.22.2.6 produces 102226 which is
>> smaller, but ought to sort higher. Hence the 4 pass sort.
>> >
>> > But you got me thinking, what if you did something like:
>> >
>> > set the numberformat to "000"
>> > sort lines of tIPList numeric by \
>> >   value(item 1 of each +0) & \
>> >   value(item 2 of each +0) & \
>> >   value(item 3 of each +0) & \
>> >   value(item 4 of each)
>> >
>> > Bob S
>>
>>
>> ___
>> use-livecode mailing list
>> use-livecode@lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Sort IP List

2018-06-29 Thread Mike Bonner via use-livecode
Thx for the clue, I see what you mean.

I had tried to get something similar to your value(item 1 of each +0)
method to work and something wasn't clicking, but after seeing yours, I
think I have it working.

sort lines of tList ascending numeric by (item 1 of each +0) & (item 2 of
each + 0) & (item 3 of each + 0) & (item 4 of each + 0)

The above seems to work fine (and I avoided using value() to avoid an
unnecessary function call), you just have to remember to set the
itemdelimiter to "." otherwise you get the error.  This may be faster
because there aren't a bunch of function calls like my first idea, though
I'm not sure how overhead compares since the numbers must still be
evaluated.

Just did some testing and it seems to be way way faster.  100k lines sort
in 3/4 of a second.

On Fri, Jun 29, 2018 at 3:18 PM Bob Sneidar via use-livecode <
use-livecode@lists.runrev.com> wrote:

> Yeah, no I get runtime error. 
>
> > On Jun 29, 2018, at 14:09 , Bob Sneidar via use-livecode <
> use-livecode@lists.runrev.com> wrote:
> >
> > Yes because your ampersand operator is not passing different arguements,
> it's concatenating the items together so that 10.2.245.6 produces the
> integer 1022456. But 10.22.2.6 produces 102226 which is smaller, but ought
> to sort higher. Hence the 4 pass sort.
> >
> > But you got me thinking, what if you did something like:
> >
> > set the numberformat to "000"
> > sort lines of tIPList numeric by \
> >   value(item 1 of each +0) & \
> >   value(item 2 of each +0) & \
> >   value(item 3 of each +0) & \
> >   value(item 4 of each)
> >
> > Bob S
>
>
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Sort IP List

2018-06-29 Thread Bob Sneidar via use-livecode
Yeah, no I get runtime error.  

> On Jun 29, 2018, at 14:09 , Bob Sneidar via use-livecode 
>  wrote:
> 
> Yes because your ampersand operator is not passing different arguements, it's 
> concatenating the items together so that 10.2.245.6 produces the integer 
> 1022456. But 10.22.2.6 produces 102226 which is smaller, but ought to sort 
> higher. Hence the 4 pass sort. 
> 
> But you got me thinking, what if you did something like:
> 
> set the numberformat to "000"
> sort lines of tIPList numeric by \
>   value(item 1 of each +0) & \
>   value(item 2 of each +0) & \
>   value(item 3 of each +0) & \
>   value(item 4 of each)
> 
> Bob S


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Sort IP List

2018-06-29 Thread Bob Sneidar via use-livecode
Yes because your ampersand operator is not passing different arguements, it's 
concatenating the items together so that 10.2.245.6 produces the integer 
1022456. But 10.22.2.6 produces 102226 which is smaller, but ought to sort 
higher. Hence the 4 pass sort. 

But you got me thinking, what if you did something like:

set the numberformat to "000"
sort lines of tIPList numeric by \
   value(item 1 of each +0) & \
   value(item 2 of each +0) & \
   value(item 3 of each +0) & \
   value(item 4 of each)

Bob S



> On Jun 29, 2018, at 10:29 , Mike Bonner via use-livecode 
>  wrote:
> 
> sort lines of plist  ascending numeric by item 1 of each &  item 2 of each &
> item 3 of each & item 4 of each  -- reverse this for your desired sort
> doesn't sort numerically (even if each key is forced to numeric with a + 0)


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Sort IP List

2018-06-29 Thread Mike Bonner via use-livecode
Actually, when using the multiple key sort, dont reverse the order since it
does it all in one go.

On Fri, Jun 29, 2018 at 11:29 AM Mike Bonner  wrote:

> Ok, now i'm curious about something.. I know its possible to designate
> multiple keys to a single sort using the form..
> sort lines of plist  by item 1 of each &  item 2 of each & item 3 of each
> & item 4 of each
> which works fine.
> But changing it to..
> sort lines of plist  ascending numeric by item 1 of each &  item 2 of
> each & item 3 of each & item 4 of each  -- reverse this for your desired
> sort
> doesn't sort numerically (even if each key is forced to numeric with a + 0)
>
> BTW, I had to go back to comments in an older version of LC to remember
> how to do the multiple-key sorts.
>
> Since it ignores the "numeric" part, if one limits ips to all 3 digit
> numbers, the sort works as expected despite sorting as  alpha.
>
> So my question is this.. Would it be a reasonable feature request to
> adjust sort so that its multiple key format respects the numeric sort type?
>
>
> On Fri, Jun 29, 2018 at 10:46 AM Bob Sneidar via use-livecode <
> use-livecode@lists.runrev.com> wrote:
>
>> A realistic expectation of IP addresses for a given network might only be
>> around 16,535 (class B network) assuming every address was in use, an
>> unlikely scenario. I thought of way to do this for an extremely large
>> number of addresses by reading a large file in 1000 line chunks into 4
>> columns of a SQL memory database, then querying using concatenation and
>> sorts on the 4 columns, and using limit 1,1000 1001,1000 2001,1000 etc. and
>> writing back to another file. The time to do this of course would be much
>> longer, but it would avoid any memory constraints.
>>
>> Bob S
>>
>>
>> > On Jun 29, 2018, at 09:35 , Mike Bonner via use-livecode <
>> use-livecode@lists.runrev.com> wrote:
>> >
>> > ## was writing this when your response showed up..
>> > Just did some tests.  For reasonable size lists of IP numbers, your
>> method
>> > is clearly faster. As lines increase the disparity shrinks (due to 4
>> > processings of the same lines rather than 1) until around 35000 lines at
>> > which point positions reverse and the disparity grows in favor of the
>> > function(each) method.
>> >
>> > After just a bit more testing, the fastest method (for anything over
>> 2
>> > lines) is to run through the whole list first converting it to numeric
>> and
>> > then do a single simple sort, but that leaves you with a straight list
>> of
>> > numbers that would then have to be re-divided into triads, so the post
>> > processing needed kills the whole idea.
>> >
>> > As for your response,
>> > Yes  the function is called by sort for each line and returns the
>> numbers
>> > to use to give that line its sort value.  It isn't as fast as I had
>> hoped
>> > most likely because it has to call a function for each line in the list.
>> > With the first method I posted, on my machine, the crossover point is
>> right
>> > around 35000 lines (at least on my system, at 35000 lines it takes 475
>> > millisec to 612 millisec vs the 4xsort)   At 200,000 lines the disparity
>> > grows to over 3 seconds difference, but i'm unsure what max length list
>> > might be reasonably expected.  The 4 sort method is by far the simplest
>> to
>> > code and is plenty fast for list under 10.
>> > The nicest part of your method is that if processing a huge list, its
>> easy
>> > to give visual feedback between each sort if need be.  But again, all
>> this
>> > is likely moot unless the ip list is huge.
>>
>>
>> ___
>> use-livecode mailing list
>> use-livecode@lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Sort IP List

2018-06-29 Thread Mike Bonner via use-livecode
Ok, now i'm curious about something.. I know its possible to designate
multiple keys to a single sort using the form..
sort lines of plist  by item 1 of each &  item 2 of each & item 3 of
each & item
4 of each
which works fine.
But changing it to..
sort lines of plist  ascending numeric by item 1 of each &  item 2 of each &
 item 3 of each & item 4 of each  -- reverse this for your desired sort
doesn't sort numerically (even if each key is forced to numeric with a + 0)

BTW, I had to go back to comments in an older version of LC to remember how
to do the multiple-key sorts.

Since it ignores the "numeric" part, if one limits ips to all 3 digit
numbers, the sort works as expected despite sorting as  alpha.

So my question is this.. Would it be a reasonable feature request to adjust
sort so that its multiple key format respects the numeric sort type?


On Fri, Jun 29, 2018 at 10:46 AM Bob Sneidar via use-livecode <
use-livecode@lists.runrev.com> wrote:

> A realistic expectation of IP addresses for a given network might only be
> around 16,535 (class B network) assuming every address was in use, an
> unlikely scenario. I thought of way to do this for an extremely large
> number of addresses by reading a large file in 1000 line chunks into 4
> columns of a SQL memory database, then querying using concatenation and
> sorts on the 4 columns, and using limit 1,1000 1001,1000 2001,1000 etc. and
> writing back to another file. The time to do this of course would be much
> longer, but it would avoid any memory constraints.
>
> Bob S
>
>
> > On Jun 29, 2018, at 09:35 , Mike Bonner via use-livecode <
> use-livecode@lists.runrev.com> wrote:
> >
> > ## was writing this when your response showed up..
> > Just did some tests.  For reasonable size lists of IP numbers, your
> method
> > is clearly faster. As lines increase the disparity shrinks (due to 4
> > processings of the same lines rather than 1) until around 35000 lines at
> > which point positions reverse and the disparity grows in favor of the
> > function(each) method.
> >
> > After just a bit more testing, the fastest method (for anything over
> 2
> > lines) is to run through the whole list first converting it to numeric
> and
> > then do a single simple sort, but that leaves you with a straight list of
> > numbers that would then have to be re-divided into triads, so the post
> > processing needed kills the whole idea.
> >
> > As for your response,
> > Yes  the function is called by sort for each line and returns the numbers
> > to use to give that line its sort value.  It isn't as fast as I had hoped
> > most likely because it has to call a function for each line in the list.
> > With the first method I posted, on my machine, the crossover point is
> right
> > around 35000 lines (at least on my system, at 35000 lines it takes 475
> > millisec to 612 millisec vs the 4xsort)   At 200,000 lines the disparity
> > grows to over 3 seconds difference, but i'm unsure what max length list
> > might be reasonably expected.  The 4 sort method is by far the simplest
> to
> > code and is plenty fast for list under 10.
> > The nicest part of your method is that if processing a huge list, its
> easy
> > to give visual feedback between each sort if need be.  But again, all
> this
> > is likely moot unless the ip list is huge.
>
>
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Sort IP List

2018-06-29 Thread Bob Sneidar via use-livecode
A realistic expectation of IP addresses for a given network might only be 
around 16,535 (class B network) assuming every address was in use, an unlikely 
scenario. I thought of way to do this for an extremely large number of 
addresses by reading a large file in 1000 line chunks into 4 columns of a SQL 
memory database, then querying using concatenation and sorts on the 4 columns, 
and using limit 1,1000 1001,1000 2001,1000 etc. and writing back to another 
file. The time to do this of course would be much longer, but it would avoid 
any memory constraints. 

Bob S


> On Jun 29, 2018, at 09:35 , Mike Bonner via use-livecode 
>  wrote:
> 
> ## was writing this when your response showed up..
> Just did some tests.  For reasonable size lists of IP numbers, your method
> is clearly faster. As lines increase the disparity shrinks (due to 4
> processings of the same lines rather than 1) until around 35000 lines at
> which point positions reverse and the disparity grows in favor of the
> function(each) method.
> 
> After just a bit more testing, the fastest method (for anything over 2
> lines) is to run through the whole list first converting it to numeric and
> then do a single simple sort, but that leaves you with a straight list of
> numbers that would then have to be re-divided into triads, so the post
> processing needed kills the whole idea.
> 
> As for your response,
> Yes  the function is called by sort for each line and returns the numbers
> to use to give that line its sort value.  It isn't as fast as I had hoped
> most likely because it has to call a function for each line in the list.
> With the first method I posted, on my machine, the crossover point is right
> around 35000 lines (at least on my system, at 35000 lines it takes 475
> millisec to 612 millisec vs the 4xsort)   At 200,000 lines the disparity
> grows to over 3 seconds difference, but i'm unsure what max length list
> might be reasonably expected.  The 4 sort method is by far the simplest to
> code and is plenty fast for list under 10.
> The nicest part of your method is that if processing a huge list, its easy
> to give visual feedback between each sort if need be.  But again, all this
> is likely moot unless the ip list is huge.


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Sort IP List

2018-06-29 Thread Mike Bonner via use-livecode
## was writing this when your response showed up..
Just did some tests.  For reasonable size lists of IP numbers, your method
is clearly faster. As lines increase the disparity shrinks (due to 4
processings of the same lines rather than 1) until around 35000 lines at
which point positions reverse and the disparity grows in favor of the
function(each) method.

After just a bit more testing, the fastest method (for anything over 2
lines) is to run through the whole list first converting it to numeric and
then do a single simple sort, but that leaves you with a straight list of
numbers that would then have to be re-divided into triads, so the post
processing needed kills the whole idea.

As for your response,
Yes  the function is called by sort for each line and returns the numbers
to use to give that line its sort value.  It isn't as fast as I had hoped
most likely because it has to call a function for each line in the list.
With the first method I posted, on my machine, the crossover point is right
around 35000 lines (at least on my system, at 35000 lines it takes 475
millisec to 612 millisec vs the 4xsort)   At 200,000 lines the disparity
grows to over 3 seconds difference, but i'm unsure what max length list
might be reasonably expected.  The 4 sort method is by far the simplest to
code and is plenty fast for list under 10.
The nicest part of your method is that if processing a huge list, its easy
to give visual feedback between each sort if need be.  But again, all this
is likely moot unless the ip list is huge.

On Fri, Jun 29, 2018 at 9:37 AM Mike Bonner  wrote:

> I don't know what speed differences there might be, but another option is
> something like this..
>
> function ipfunc pIp
>set the itemdel to "."
>set the numberformat to "###" -- force length of each chunk to 3
>
> -- append the numbers together sans "." with padded 0's using numberformat
>repeat for each item tItem in pIp
>  put tItem +0 after tIp -- do the add to force the numberformat to
> work
>end repeat
>return tIp
> end ipfunc
>
> And then use it like so..
> sort lines of myIpList ascending numeric by ipfunc(each)
>
>
> On Fri, Jun 29, 2018 at 9:14 AM Bob Sneidar via use-livecode <
> use-livecode@lists.runrev.com> wrote:
>
>> Hi all.
>>
>> I somehow got on to how to sort IP addresses, seeing they are not real
>> numbers, and read in the dictionary that the sort command is a "stable
>> sort". This occured to me:
>>
>> function sortIPList pIPList
>>set the itemdelimiter to "."
>>sort lines of pIPList numeric by item 4 of each
>>sort lines of pIPList numeric by item 3 of each
>>sort lines of pIPList numeric by item 2 of each
>>sort lines of pIPList numeric by item 1 of each
>>return pIPList
>> end sortIPList
>>
>> Enjoy!
>>
>> Bob S
>>
>>
>> ___
>> use-livecode mailing list
>> use-livecode@lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Sort IP List

2018-06-29 Thread Bob Sneidar via use-livecode
First, your function returns a single line of numbers. With 30,000 lines of 
input, yours takes 9 ticks, mine 8. 

Bob S


> On Jun 29, 2018, at 08:37 , Mike Bonner via use-livecode 
>  wrote:
> 
> I don't know what speed differences there might be, but another option is
> something like this..
> 
> function ipfunc pIp
>   set the itemdel to "."
>   set the numberformat to "###" -- force length of each chunk to 3
> 
> -- append the numbers together sans "." with padded 0's using numberformat
>   repeat for each item tItem in pIp
> put tItem +0 after tIp -- do the add to force the numberformat to
> work
>   end repeat
>   return tIp
> end ipfunc
> 
> And then use it like so..
> sort lines of myIpList ascending numeric by ipfunc(each)
> 
> 
> On Fri, Jun 29, 2018 at 9:14 AM Bob Sneidar via use-livecode <
> use-livecode@lists.runrev.com> wrote:
> 
>> Hi all.
>> 
>> I somehow got on to how to sort IP addresses, seeing they are not real
>> numbers, and read in the dictionary that the sort command is a "stable
>> sort". This occured to me:
>> 
>> function sortIPList pIPList
>>   set the itemdelimiter to "."
>>   sort lines of pIPList numeric by item 4 of each
>>   sort lines of pIPList numeric by item 3 of each
>>   sort lines of pIPList numeric by item 2 of each
>>   sort lines of pIPList numeric by item 1 of each
>>   return pIPList
>> end sortIPList
>> 
>> Enjoy!
>> 
>> Bob S
>> 
>> 
>> ___
>> use-livecode mailing list
>> use-livecode@lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>> 
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Sort IP List

2018-06-29 Thread Mike Bonner via use-livecode
I don't know what speed differences there might be, but another option is
something like this..

function ipfunc pIp
   set the itemdel to "."
   set the numberformat to "###" -- force length of each chunk to 3

-- append the numbers together sans "." with padded 0's using numberformat
   repeat for each item tItem in pIp
 put tItem +0 after tIp -- do the add to force the numberformat to
work
   end repeat
   return tIp
end ipfunc

And then use it like so..
sort lines of myIpList ascending numeric by ipfunc(each)


On Fri, Jun 29, 2018 at 9:14 AM Bob Sneidar via use-livecode <
use-livecode@lists.runrev.com> wrote:

> Hi all.
>
> I somehow got on to how to sort IP addresses, seeing they are not real
> numbers, and read in the dictionary that the sort command is a "stable
> sort". This occured to me:
>
> function sortIPList pIPList
>set the itemdelimiter to "."
>sort lines of pIPList numeric by item 4 of each
>sort lines of pIPList numeric by item 3 of each
>sort lines of pIPList numeric by item 2 of each
>sort lines of pIPList numeric by item 1 of each
>return pIPList
> end sortIPList
>
> Enjoy!
>
> Bob S
>
>
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode