On 01/16/2013 07:16 PM, J. Landman Gay wrote:
On 1/16/13 9:06 AM, Richmond wrote:
I have a socking great text file that reads in part something like this:

Cook my cheese
fishface1
finish
Shave my legs
fishface2
finish
Paint my fingernails
fishface3
finish
Wax my arms
fishface4
finish

and so it goes for about 72 pages (!!!)

Now what I needs is a reordered lilst like this:

fishface1
Cook my cheese
finish
fishface2
Shave my legs
finish
fishface3
Paint my fingernails
finish
fishface4
Wax my arms
finish

Assuming a field 1 with the original list, and a field 2 to receive the sorted list:

on sortData
  put fld 1 into tData
  repeat with x = 1 to the number of lines in tData step 3
    put line x to x+2 of tData into tSet
    sort lines of tSet by specialSort(each)
    put tSet & cr after tNewData
  end repeat
  put tNewData into fld 2
end sortData

function specialSort pLine
  if last char of pLine is a number then return 1
  if pLine = "finish" then return 3
  return 2
end specialSort


That one does the job superbly. Thanks Mrs Gay!!!!

Richmond.

_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to