Using Sort to Rearrange the Contents of Each Line in a List |
|
first,last,phoneAnd I wanted to re-arrange the contents of each line so that the last name was first, followed by the first name, then the phone. This did it:
jacque,gay,724-1596
bob,smith,123-1234
mary,jones,345-6929
john,doe,939-2939
You could alter this to sort data in one field based on the order in another field, or to use any arbitrary order you want. Lots of variations are possible.local theCount,theRightOrder on dosort put fld 1 into theData -- the original list put "2,1,3" into theRightOrder -- the key line repeat for each line l in theData put 0 into theCount sort items of l by mySort(each) put l & return after theNewData end repeat put theNewData into fld 2 end dosort function mySort add 1 to theCount return item theCount of theRightOrder end mySort
Posted on 1/14/03 by Jacqueline Landman Gay (HyperActive Software) to the Use-Revolution list (See the complete post/thread)