# How must elemental symbols be ordered in the formula for a compound?

An online problem asked me to find the molecular formula of a certain substance given its mass composition. I found that it was $\ce{N_5P_5Cl_{10}}$. It was incorrect and told me the ordering of my symbols was wrong. I switched it to $\ce{N_5Cl_{10}P_5}$ because that's the order that they appear on the periodic table. It marked me wrong again and told me that the answer was $\ce{P_5N_5Cl_{10}}$, but didn't tell me why it must be ordered this way. Is there a convention that must be followed here?