Re: Sorting IP addresses
Re: Sorting IP addresses
- Subject: Re: Sorting IP addresses
- From: Emmanuel <email@hidden>
- Date: Wed, 17 Dec 2003 16:17:42 +0100
At 7:37 AM -0700 17/12/03, Marconi wrote:
>
Given a list of IP addresses, I need to sort them in proper (ascending) order. That is, I need a routine which knows that 205.192.32.45 comes AFTER 65.163.82.130 and so forth.
Suppose the list of addresses is stored in l:
----------------- untested -- requires the Satimage osax
set text item delimiters to return
set x to l as text
set x to change "(^|\\.)([0-9])(\\.|$)" into "\\100\\2\\3" in x with regexp
set x to change "(^|\\.)([0-9]{2})(\\.|$)" into "\\10\\2\\3" in x with regexp
set l to text items of x
-----------------
>
Can anyone help me out? (I'm going to be doing this in BBEdit.)
Of course, that's more easily tested in Smile, since you can run each line and see what's going on.
Emmanuel
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.