Custom sorting question

Devin Asay devin_asay at byu.edu
Thu Apr 20 13:56:59 EDT 2006


I know this should be possible, but I'm having a heckuva time getting  
it to work.

I want to sort some data that looks like this when it comes out of  
the database, put into variable tRawData (the white spaces are tabs;  
the random characters are unicode data, waiting to be uniencoded into  
a field):

26	ба´бушка	grandmother	Ба´бушка живёт у нас  
в кварти´ре.	grandma
54	брат	brother	Э´то мои´ брат и сестра´.	 
brother
110	внук	grandson	Вот мой де´душка. Са´ша то 
´Ð¶Ðµ его´ внук.	grandson
111	вну´чка	granddaughter	Здесь живут Кругло´Р
²Ñ‹. Их вну´чка то´же живёт здесь.	granddaughter
149	Всё хорошо,что хорошо кончается.	All's  
well that ends well.	Всё хорошо´, что хорошо´ кР
¾Ð½Ñ‡Ð°Â´ÐµÑ‚ся.	Allswellthatendswell
250	де´вочка	little girl	Моя´ сестра´ ещё ма 
´Ð»ÐµÐ½ÑŒÐºÐ°Ñ де´вочка.	littlegirl
259	де´душка	grandfather	Мой де´душка то´же Р
¶Ð¸Ð²Ñ‘Ñ‚ здесь.	grandfather
272	де´ти	children	На´ши де´ти о´чень Ð±Ñ‹Â´ÑÑ‚Ñ 
€Ð¾ расту´т.	children
314	дочь	daughter	Э´то Ната´лья Ива´новна. Р
›ÐµÂ´Ð½Ð° её дочь.	daughter

Another variable, lSortOrder, contains the order I want the lines to  
appear:

259,26,110,111,272,314,149,250,54

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?

Devin

Devin Asay
Humanities Technology and Research Support Center
Brigham Young University




More information about the use-livecode mailing list