Finding and sorting by diacriticals again

Wouter Abraham wouter.abraham at pi.be
Wed Mar 12 11:40:01 EST 2003


> function ctnSort pTextToSort
> get the SortOrder of me #### that is if the custom property is also in 
> the same object as the script
> repeat for each line kk in it
> put kk after so
> end repeat
> set the caseSensitive to true #### important to make the offset 
> function work correctly
> repeat for each item ii in pTextToSort
> repeat for each char cc in ii
> put offset(cc,so) & space after tempVar
> end repeat
> delete last char of tempVar
> put tempVar & "," & ii & cr after theSorter
> put "" into tempVar
> end repeat
> sort lines of theSorter numeric by first item of each
> repeat for each line ll in theSorter
> put item 2 of ll & "," after theResult
> end repeat
> delete last char of theResult
> return theResult
> end ctnSort
>
> Way cool. Thanks for posting that.
>
> -- 
>  Richard Gaskin
>  Fourth World Media Corporation
>  Developer of WebMerge 2.2: Publish any database on any site


Hi again,

After a 4W_MetaBench-like test (tnx mr. Gaskin your name made me think 
about it :^) the previous function should be changed to :

function ctnSort pTextToSort
   get fld "thetable"
   repeat for each line kk in it
     put kk after so   -- sortOrder
   end repeat
   set the caseSensitive to the hilite of button "caseSensitive"
   repeat for each item ii in pTextToSort
     repeat for each char cc in ii
       put offset(cc,so) & space after tempvar  #### caseSensitive 
function
     end repeat
     delete last char of tempvar
     put tempvar & cr after thesorter
     put "" into tempvar
   end repeat
   sort lines of thesorter numeric
repeat for each line ll in thesorter    ##### changed
     repeat for each word ww in ll
       put char ww of so  after theresult
     end repeat
     put "," after theresult
end repeat                                            ##### til here :^)
   delete last char of theresult
   return theresult
end ctnSort

Afterthought:
This is only a remedy until the sort command gets "fixed" in the 
mc-engine to so that it can come up to real speed.
May be it would be nice to have it extended to something were the user 
has the choice between the build in sort order or his own

Have a nice day,
WA




More information about the use-livecode mailing list