I don't have a ready answer.
Possibly storing a multi-dimensional array of order and position updates and looping through these or writing custom logic that depends on order of events.
Its not something I'm familiar with. Were it my task, it would be something I work out through coding experience and trial and error.
Comment