question about position of objects

I am creating several cubes which is right next to each other using GL_QUAD, i.e. a side of the cube would share the same location in the 3d world. My code has problem determining which cube is in front of which in the case where 2 cubes have sides that share the same position in the 3d world. Is there a way that I could tell openGL which cube is in front of which??
Any help would be appreciated.

here is the ss

I was setting the zNear too close to zero.