Intelligent sorting: A bit of a poser

DunbarX at aol.com DunbarX at aol.com
Thu Jul 1 10:30:12 EDT 2010


Probably could streamline this, but:

function separateNumbers var
    repeat with y =   1 to the number of lines of var
       repeat with u = 1 to the number of chars of line y of var
          if char u of line y of var is   in "0123456789" then
             put comma before char u of line y of var
             exit repeat
          end if
       end repeat
    end repeat
    return var
end separateNumbers

function separateNumbers var
    repeat for each char tchar in var
       if tChar is in "0123456789" then put comma before tChar
    end repeat
    return var
end separateNumbers

on mouseUp
    put separateNumbers(fld 2) into temp
    sort temp numeric   by item 2 of each & item 1 of each
    sort temp by item 1 of each
    replace comma with empty in temp
    put temp into fld 2
end mouseUp



More information about the use-livecode mailing list