Sorting Multiple Fields

J. Landman Gay jacque at hyperactivesw.com
Sat Apr 30 23:43:38 EDT 2005


On 4/30/05 6:02 PM, Roger Guay wrote:

> I have 6 list fields side-by-side each with the same number of  lines,  
> with synchronized scrolling and synchronized hilitedLines.   Is there an 
> easy way to sort the first field and have the data in the  other fields 
> follow the sort.  That is to sort the whole group on the  first field?

If you want to twist your brain in knots, you can sort using a function:

local lKeyData, lLineCounter

on sortBy keyField -- parallel sorting of linked flds
   put fld keyField into lKeyData
   put "data1,data2,data3" into dataFields -- fill in your fld names here
   repeat with i = 1 to the number of items of dataFields
     put 0 into lLineCounter -- must be reset prior to each sort
     sort lines of fld (item i of dataFields) by key()
   end repeat
end sortBy

function key
   add 1 to lLineCounter
   return line lLineCounter of lKeyData
end key

Based on an old HyperCard script by Brett Sher.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com


More information about the use-livecode mailing list