How to order a list - A challenge


Dave
 

Hi,

I’ve written a Handler to do the following:

on GetOrderedList(theMasterList,theNewList)

return myOrderedList
end GetOrderedList

theMasterList:
MasterOrderList
AAA
BBB
CCC
DDD
EEE

theNewList t:
DDD
BBB
CCC

Return list:
BBB
CCC
DDD

I’ve got it working but its very clunky, I was wondering the fastest way to do it is in AppleScript.

The way it currently works is to copy theMasterList to myTempList, then remove all the items that are not in theNewList.
Then create myOrdered list by stepping thru theMasterList and then adding the correspond entry from myTempList.

it works but its slow! Any way to improve it?

Thanks a lot
Dave


Dave
 

Oh and, if the item from theNewList is not in the theMasterList the it should be added to the end of the myOrderedList.

On 1 May 2020, at 11:06, Dave <dave@...> wrote:

Hi,

I’ve written a Handler to do the following:

on GetOrderedList(theMasterList,theNewList)

return myOrderedList
end GetOrderedList

theMasterList:
MasterOrderList
AAA
BBB
CCC
DDD
EEE

theNewList t:
DDD
BBB
CCC

Return list:
BBB
CCC
DDD

I’ve got it working but its very clunky, I was wondering the fastest way to do it is in AppleScript.

The way it currently works is to copy theMasterList to myTempList, then remove all the items that are not in theNewList.
Then create myOrdered list by stepping thru theMasterList and then adding the correspond entry from myTempList.

it works but its slow! Any way to improve it?

Thanks a lot
Dave