Fix execution order with "names"

Fixes #13312. Used fractional parts of floats to ensure correct sort
order. The issue with previous solution to use order + name_order was
that all states come with preassigned order, and thus order + name_order
will match the order of the following states. This solution limits the
maximum value of name_order to 9999 before the same issue arises again.

I don't quite understand why the order_chunks function is duplicated
twice. I updated both instances.
Merge pull request #19247 from Nikerabbit/ordering

Fix execution order with "names" in relation to other states