• 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: Marconi <email@hidden>
  • Date: Thu, 18 Dec 2003 09:40:11 -0700

The answers thus far have not actually addresses the sorting but rather getting the IP addresses into a 'sortable' form. That is, rather than sort four times -- once for each quad -- convert the IPs into a more easily sorted form and sort just once. Of course, I need to preserve the original IPs as well, for display and writing to a file, so it looks like the consensus is:

(Starting with a file of IP addresses, one per line, somewhere between 500-1000 lines...)

1) Read the file into an array. We'll make the unchanged IP address the first element in each record of the array.

2) Traverse the array converting the IP address to a more sortable form. Put that version into the respective second element in each record.

It has been suggested to convert to ASCII text characters and to convert to the decimal equivalent of the IP address. I would note that using ASCII means that I would need a case-sensitive sort, yes? Might be easier to stick with numbers.

3) sort the array based on the second element.

4) Write the first element of each array record back to the file.

Sound workable?

I have very limited AS skills and have done no scripting arrays at all. Did all sorts of such things in Pascal, years ago.

Anyone care to point me to a good source of info on using arrays in AS?

Oh, could use an example of sorting too....
_______________________________________________
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.

  • Follow-Ups:
    • Re: Sorting IP addresses
      • From: Graff <email@hidden>
    • Re: Sorting IP addresses
      • From: Emmanuel <email@hidden>
    • Re: Sorting IP addresses
      • From: Doug McNutt <email@hidden>
    • Be the first on your block to run OS X 10.3.2!
      • From: Mr Tea <email@hidden>
References: 
 >Sorting IP addresses (From: Marconi <email@hidden>)
 >Re: Sorting IP addresses (From: Steve Mills <email@hidden>)
 >Re: Sorting IP addresses (From: Graff <email@hidden>)

  • Prev by Date: Re: Filter reference form question
  • Next by Date: Be the first on your block to run OS X 10.3.2!
  • Previous by thread: Re: Sorting IP addresses
  • Next by thread: Be the first on your block to run OS X 10.3.2!
  • Index(es):
    • Date
    • Thread