Perhaps the easiest solution for the fences specifically would be to split it up into individual sprites (and use hierarchies to stich them back together), so that sorting by Y position would approximate more closely to what you'd expect.
cutting a long object into several parts is a bad idea. 1 object (fence) will turn into 5-6, and there can be 100 or more fences and there are still other objects.
It may seem that this is a simple way, but it is not, there are also other problems - when draging the fence, it becomes visible that it consists of several parts, between which the distance can change (+-1px). I tried this method