addressbook data collection > sort by name ?

Hi,

I am collecting a bunch of addressbook data and storing it into a tab delimited file which ends up looking like this:

001_nickname full_name email@email.com Groups: [group_name1, group_name2l], Phone: [work: (555) 555-5555, home: (555) 555-5555]

So because I am generating an id (“001”) at the beginning of the nickname field, and I need to retreive the data from addressbook alphabetically by first name.

I am accessing contact cards this way:


	tell application "Address Book" to tell people
				repeat with thisPerson in it
					tell thisPerson to if (count emails) > 0 then
						set {o, p, e, el, g, b, n, f, l, mn, sn, nn, ph, phl} to its {organization, name, email's value, label of email, name of group, birth date, note, first name, last name, middle name, suffix, nickname, value of phone, label of phone}
						-- analyze all data and copy it to the end of a list...
					end tell
				end repeat
	end tell

-- put the contents of the list with tab delimiters into a text file...

So I am wondering is there some way to do something like:

	tell application "Address Book" to tell people sorted by first name

?

Thank you.

-patrick

Not easily (at least, I don’t think so). I took a look in Address Book’s Library (accessible by dragging any app, in this case Address Book, to the Script Editor icon in the dock) and there’s no command that I found connected with “Sort”. This is probably possible with GUI Scripting, however I’ve been cautious to delve into this area. Poke around and see what you can find.
Sorry to not be of more help.