The correct order of elements in the formula for an ionic compound is:
The metal comes first, followed by the nonmetal.
In ionic compounds, metals (which typically have a positive charge) are written before nonmetals (which usually have a negative charge). For example, in sodium chloride (NaCl), sodium (the metal) is written before chlorine (the nonmetal).