SORT by length

hh hh at
Tue Aug 8 06:20:27 EDT 2017

> Richmond wrote:
> Sorry about the asterisks . . .
> That is what happens when one copy-pastes directly from the LiveCode 
> scriptEditor into Thunderbird.

Specify the default character encodings for sending and receiving messages
Menu location: Thunderbird > Preferences > Display > Formatting - Advanced button

@Sort by length

As several others said:
     sort str [ascending|descending] numeric by length(each)
works perfectly.

But the first part of your script sorts correctly numeric by length if and only if
there is NO COMMA in the string to sort ... You sort by item 2, of course you could
sort by item -1.

Nevertheless the one-liner above will be *much* faster.

> Richmond wrote:
> on mouseUp
>   put empty into rSortByLength
>   put fld "CL" into tText
>   repeat for each word tLine in tText
>     put tLine&"," &the length of tLine&return after rSortByLength
>   end repeat
>   delete char -1 of rSortByLength
>   sort lines of rSortByLength descending numeric by item 2 of each
>   put empty into fld "CL"
>   put rSortByLength into fld "CL"
>   --
>   put 1 into KOUNT
>   repeat until line KOUNT of fld "CL" is empty
>     delete the last char of line KOUNT of fld "CL"
>     delete the last char of line KOUNT of fld "CL"
>     add 1 to KOUNT
>   end repeat
> end mouseUp

More information about the Use-livecode mailing list