• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Sorting IP addresses
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Sorting IP addresses (From: Marconi <email@hidden>)

  • Prev by Date: Reading Data from other file
  • Next by Date: Re: Strange behavior on 10.2.6 - mount volume
  • Previous by thread: Sorting IP addresses
  • Next by thread: Re: Sorting IP addresses
  • Index(es):
    • Date
    • Thread