• 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: Doug McNutt <email@hidden>
  • Date: Wed, 17 Dec 2003 10:56:52 -0700

At 07:37 -0700 12/17/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.

A warning about something you should NOT do:

Don't try adding leading zeros to those quads in a way that will show up in the source. The last two quads in 205.192.032.045 will be interpreted as octal numbers in compliance with C language defaults by IP software.

You can convert each quad to a number multiplying the first by 256*256*256, the second by 256*256 and so on then adding the results to get a sorting number. Be careful though. AppleScript will not allow you to use a 32 bit unsigned integer and will convert to floating point. It'll probably be OK.

--
--> There are 10 kinds of people: those who understand binary, and those who don't <--
_______________________________________________
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: Re: Sorting IP addresses
  • Next by Date: Re: Strange iDisk name (e.g., name-1)
  • Previous by thread: Re: Sorting IP addresses
  • Next by thread: Re: Sorting IP addresses
  • Index(es):
    • Date
    • Thread