Ordering time... also in ASOC.

Let’s say I have a list like so:

{{content:"Hi.", |date|:date "Wednesday, May 5, 2010 3:15:00PM"}, {content:"Weegee.", |date|:date "Thursday, May 6, 2010 4:00:00AM"}, {content:".", |date|:date "Thursday, May 6, 2010 5:00:00AM"}}

I want AppleScript to order these lists and return a list that just shows the content of these lists.
I am using AppleScript Objective-C, so there could be more ways than one.

NOTE: My time format is different then others, so compiling these dates could end up to be 12AM of the original date. Please check… and find a simple solution. :wink:

Hi, Dylan.

“These lists” are actually records. :slight_smile:

I assume you want them ordered them by |date|. I’d write a “compare |date|s” script object to go with this customisable sort handler.

script compareDates
	on isLess(a, b)
		(a's |date| < b's |date|)
	end isLess
	on isGreater(a, b)
		(a's |date| > b's |date|)
	end isGreater
	on swap(a, b)
	end swap
	on shift(a, b)
	end shift
end script

set myList to {{content:".", |date|:date "Thursday 6 May 2010 05:00:00"}, {content:"Hi.", |date|:date "Wednesday 5 May 2010 15:15:00"}, {content:"Weegee.", |date|:date "Thursday 6 May 2010 04:00:00"}}

CustomQsort(myList, 1, -1, compareDates)

repeat with thisRecord in myList
	set thisRecord's contents to thisRecord's content -- !
end repeat

myList --> {"Hi.", "Weegee.", "."}