First, don't use system compare to check y positions, because it doesn't pick objects. Doing that doesn't make the cap work, though, because it picks all the buildings with a less .y, and doesn't know which one to put the player in front of.
What I recommend doing is putting all the objects you want to sort into a family and use the event:
if family is on screen
for each family (ordered): family.y ascending
Keep in mind though that 'is on screen' doesn't take into account zoom or screen rotation, so you might need to use a different method of determining what's on screen, like putting an invisible sprite over the screen, setting it to box collisions and check for collisions with the family.
You could use PR's method, but I think this way is easier because all you need to do to get another object to sort is add it to the family.