Devin Asay wrote:

I read the dictionary entry for 'sort container' carefully, and found a couple of sample scripts for similar things from old use-rev postings. This is what I came up with, but it didn't do what I want. I think it boils down to my not understanding how to create custom sort orders.

local lCount,lSortOrder

on updateList
## sort the rawLessonData by item 1 of each line, according to the term list
  put the rawLessonData of fld "vocablist" into tRawData
  put "59,26,110,111,272,314,149,250,54" into lSortOrder
  put 0 into lCount
  sort lines of tRawData by termOrderSort(each)

  -- do stuff with the sorted list
end updateList

function termOrderSort
  add 1 to lCount
  return item lCount of lSortOrder
end termOrderSort

Can anyone advise me?

The way it is now, termOrderSort is returning a number from the item list (such as 259), and the lines will sort numerically using those numbers. What you want is for "259" to be returned as "1" and "26" to be returned as "2", etc. Then the sort works. So do this:

local lSortOrder -- this is the only local you need

on updateList
  put the rawLessonData of fld "vocablist" into tRawData
  put "259,26,110,111,272,314,149,250,54" into lSortOrder
  sort lines of tRawData by termOrderSort(word 1 of each)

  -- do stuff with the sorted list
end updateList

function termOrderSort tNum
  return itemoffset(tNum, lSortOrder) -- this returns "1,2,3,4,5,etc"
end termOrderSort

Using "word 1 of each" sends the actual number in your raw data to the sort function. The sort function gets the item offset of that number from the sort order list. It returns that offset as an integer that will force the data to sort in the proper order; that is, "259" becomes "1", etc.

--
Jacqueline Landman Gay         |     [EMAIL PROTECTED]
HyperActive Software           |     http://www.hyperactivesw.com
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to