e.g. of a single simplified record:
tScores[1]["Date"] = 12/25/16
tScores[1]["ID"] = 0105
tScores[1]["Email"] = user1@example.com
From there, I'm trying to SORT this array using the guide for a one-dimensional array:
http://lessons.livecode.com/m/4071/l/11 ... t-an-array
But it doesn't work:
Code: Select all
get the keys of tScores
sort lines of it international ascending by tScores["ID"]
split it by return
put 1 into tNextIndex
repeat for each element tIndex in it
put tScores[tIndex] into tSortedArray[tNextIndex]
add 1 to tNextIndex
end repeat
Code: Select all
sort lines of it dateline descending by tScores["Date"]
I have a theory that it doesn't work because it's looking in the wrong 'dimension' of the array for the key "ID". Is this correct? If so, how do I correct my code so that the sort function looks in the second dimension rather than the first?
OPTION 2. Since this array is going into a datagrid, I would also be happy to just sort the dgData of the datagrid directly. However the guide on this page
http://lessons.livecode.com/m/datagrid/ ... y-s-values
results in a semantic error (missing an end paren, which is odd because there are no parens in that code or in mine). I've never used the "dispatch" command and I don't really know how to adapt what I'm seeing in the guide to a simple mouseup on the group itself. Do I need to WRITE the sortDataByKey command somwhere, or is it automatically understood by the datagrid itself?