[OT] reOrdering text
Richmond
richmondmathewson at gmail.com
Wed Jan 16 14:25:22 EST 2013
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.
More information about the use-livecode
mailing list