Determining relative order of two objects?

I'm looking for some way to determine the relative order of objects. So, given Object A and Object B, I want to know which one is in front of the other.

I'm aware that I can change the order, e.g., deliberately move Object A immediately in front of or immediately behind Object B, but that's not what I want to do.

My immediate goal here is to be able to change the order to put a particular object behind a specified shaperange (e.g., put it immediately behind the "back-most" shape in a shaperange).