Sorting data in a data source

According to the reference above, a data source can be displayed as sorted, but the actual data is still in the order in which it was entered.

I need the data within the data source to be in the same order as it is displayed in the table it is connected to. I will be changing the information (adding new, updating existing, and deleting existing data). I will also be drag-and-dropping this data into other tables/outlines. How can I get the data in the data source to match the order that it is displayed? Any thoughts appreciated.

Brad Bumgarner, CTA

Here, some sample code:

on will open theObject
	set theDataSource to data source of table view "x" of scroll view "x" of theObject
	tell theDataSource
		make new data column at the end of the data columns with properties {name:"x1", sort order:ascending, sort type:numerical, sort case sensitivity:case sensitive}
		make new data column at the end of the data columns with properties {name:"x2", sort order:ascending, sort type:alphabetical, sort case sensitivity:case sensitive}
	end tell
	set sorted of theDataSource to true
	set sort column of theDataSource to data column "x1" of theDataSource
end will open

Thanks for your reply.

I have done what you show in your example. The problem is that even though the data is appears sorted in the table, the actual is in it’s original order, ex.: if I enter data in the following order

abc — the data as entered into the data source

def — the data as it appears in the table

If I click on the 2 row, I would expect to get “def” (as shown in the second set), however what I get is “abc” (as shown in the first set).

It occurred to me yesterday (after I posted) that I will need to pull the data out of the data source, sort it and put it back into the data source. Fortunately, I will have less than 50 entries, so sorting will be quick.

Thanks again,
Brad Bumgarner, CTA

I’ve run into this exactly same problem - is there a solution to this riddle already? Thanks.

The only solution I have found is to sort the data itself (not the data source) and put the data into the datasource sorted the way you want it.

I don’t know if this has been addressed within the datasource code itself.

Brad Bumgarner, CTA

Ah, bad news again. For large tables this could be very slow… (reminds me of someone saying AppleScript is easy for the things it can do, but extremely hard for the others)