Re: Sorting IP addresses
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.