Make a family with all the objects that you need to manage Z order for.
Give the family a numeric variable to keep track of their Y position.
Every tick, set that variable to their Y position, then update family's Z order.
You can check on an 'every X seconds' interval or only when the character moves if you want to save on CPU usage