The unwritten ‘rule’ is first, 天公 (tian-gong). Then you move inside to the main altar. Generally the deity on your right hand side is the most ‘senior’ or important, but some temples might arrange it differently with the main one in the middle. If there are other altars/deities, continue towards your left and to the back until you make a round back to the front (if possible).