It is conventional to write the more electropositive element in a compound first and the more electronegative element last. For example, in the formula of sodium chloride, sodium is cation (or electropositive) and chlorine is electronegative element. Thus, NaCl is the correct formula and not ClNa.
Similarly, in the formula of water (H2O), hydrogen ion is cation (electropositive) and hydroxyl ion (OH-) is the anion. Thus, conventionally H2O is the correct formula.