Just because it’s not random in some languages doesn’t mean you should ever rely on it. You’re betting on the data structure’s hash function to never change, which I don’t think most language implementers are willing to guarantee. Typically you should use some kind of ordered map if the language provides it. As Lua doesn’t, @joule’s solution is the best way.
All I say is this: such a non deterministic behaviour has no practical use and can be considered as a design flaw. A programming language should always focus on its practical use. Let’s take JavaScript, of course orders in object structures are kept intact, and it still is blazingly fast. I will fill in a bug report at lua.org… not!