How is the order of elements decided when talking about compounds?


For example, why is it NaCl instead of ClNa?

In: 2

Positive ion then negative ion.

In non ionic compounds, carbon then hydrogen then the other elements.

Or the central atom of a polyatomic ion is listed first.

Both are actually acceptable but usually its done by metals first(for inorganics) and then the heaviest element takes priority

but i only really cover organic chem so i could be wrong
Edit- turns out chem doesn’t work with my head when im half asleep, see other peoples answers

It depends on the type of compound.

Sodium chloride is an ionic compound. Ionic compounds are named by first saying the cation (positive ion) and then the anion (negative ion). In sodium chloride, sodium is the cation and chlorine is the anion, thus: NaCl.

There is a process for covalent and metallic compounds as well, but they have more steps so I’m going to leave it at “they exist” for this post. I’m not a chemist, I’ve just taken a few chem classes, so I don’t think I can reduce it very well for ELI5 but I hope somebody else does!

Just like how mathematics has order of operations, so does chemistry. Generally for simple compounds you organize them in terms of increasing electronegativity, H2O, HCl, NaCl, etc. For more complicated molecules you want them organized by central atom and then functional groups, so rather than H4C you would instead write CH4. It is also generally good practice to differentiate molecules with similar structures by writing them differently C2OH6 can be either ethanol (C2H5OH) or dimethyl ether (CH3OCH3) one of those makes a party and the other makes a wake.