Does the layer order dictate how the renderer/filter generates the code?
Yes, the general rule is items lower in the layer stack get outputted first.