As you will see at the end of the script, I was creating a list for each event by extracting "event_start_date" and "event_external_ID".My thinking was: if I can sort this list based on the date, then I will also sort the event_external_ID.I am not sure I have explained myself.Thanks.L.

Re: Sorting ical events by starting date

Add a use framework "Foundation" statement and this:

Applescript:

set anArray to current application's NSArray's arrayWithArray:MySortingListset theDesc to current application's NSSortDescriptor's sortDescriptorWithKey:"start_date" ascending:trueset sortedList to (anArray's sortedArrayUsingDescriptors:{theDesc}) as list

If all you want is the sorted IDs, then change the last line to this:

Applescript:

set sortedList to ((anArray's sortedArrayUsingDescriptors:{theDesc})'s valueForKey:"eventID") as list

Re: Sorting ical events by starting date

Shane Stanley wrote:

Add a use framework "Foundation" statement

Beautiful !!!Thanks !

PS: I must admit I feel like God on one side and mortals on the other.Gods are those that know "Foundation" ....Yesterday, I wasted two hours trying to adjust this sorting algorithm (see below) to list of records, obviously without success. And the only thing I got was an headache ... ;-)