What if, when your character 'Y' is higher than your door sprite 'Y', bring the door in front.
When the character 'Y' is lower than the door sprite 'Y', bring the character to the front.
You can try to do that with a family and include all the objects that you want to function the same way