Intelligent sorting: A bit of a poser

Dave Cragg dave.cragg at lacscentre.co.uk
Thu Jul 1 11:45:07 EDT 2010


Coming late to this. 

It should handle cases where there are commas in the original text. I don't know how it scales with large data sets.

function specialSort tData
   put "(^.*?)([0-9]*$)" into tRE
   
   put "" into tData2
   repeat for each line tLine in tData
      get matchText(tLine, tRE, tS, tNum)
      put tS & comma & tNum & cr after tData2
   end repeat
   sort lines of tData2 numeric by item -1 of each
   sort lines of tData2 by item 1 of each
  
   put "" into tData3
   repeat for each line tLine in tData2
       put item 1 to -2 of tLine & item -1 of tLine & cr after tData3
   end repeat
   
   return tData3
   
end specialSort




More information about the use-livecode mailing list