No subject

Ken Ray kray at sonsothunder.com
Fri Apr 1 16:22:16 EST 2005


On 4/1/05 11:42 AM, "Howard Bornstein" <howard.bornstein at gmail.com> wrote:

> On Mar 29, 2005 10:15 AM, Melitón Cardona Torres <toncardona at mac.com> wrote:
>> I have this in a field:
>> 
>> IPAE 16
>> IPAE 1
>> IPAE 7
>> LAG 1
>> JKAL 3
>> JKAL 11
>> JKAL 2
>> 
>> and I wish to get this (same alphabetical order, sorted numeric by
>> second word of each):
>> 
>> IPAE 1
>> IPAE 7
>> IPAE 16
>> LAG 1
>> JKAL 2
>> JKAL 3
>> JKAL 11
>> 
> Here's a quick and dirty solution. Assume the data is in a filed
> "data" and you have a button to do the sort. Use this handler in the
> button.
> 
> on mouseUp
>   put fld "data" into dataholder
>   put the number of lines of dataholder into linecnt
>   repeat with i = 1 to linecnt
>     if word 1 of line i-1 of dataholder <> word 1  of line i of dataholder
> then
>       put line i of dataholder&return after sorter
>     end if
>     if word 1 of line i+1 of dataholder = word 1 of line i of dataholder then
>       put line i+1 of dataholder&return after sorter
>     else
>       sort lines of sorter numeric by word 2 of each
>       put sorter after sorteddata
>       put empty into sorter
>     end if
>   end repeat
>   put sorteddata into fld "data"
> end mouseUp

I still think it's easier to let Rev handle the sorts:

  put fld 1 into tData
  sort tData numeric by word 2 of each
  sort tData by word 1 of each
  put tData into fld 2

Just my 2 cents,

Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com




More information about the use-livecode mailing list