do table orders get mixed up if you save them one way
and you load them in when you join a new server?
using data stores
do table orders get mixed up if you save them one way
and you load them in when you join a new server?
using data stores
A data store is, according to the official documentation, similar to a dictionary (key-value pairs). Considering this, you shouldn’t have to worry about the order in which the data is retrieved.
Though, to answer your question, I highly doubt that the order of key-value pairs would be mixed up between sessions.
If you are truly concerned about this, and you are just storing positive integers, you may consider using an Ordered Data Store.
I do not understand how this is an alternative solution or one that should be recommended to people. I don’t think anyone would want to store separate numbers into ordered datastores when you could just store them in one table in a regular datastore…
To answer the question in the first post:
{"hello", "world", "this", "is", {1, 2, 3}, "an", "array"}
for i = 1, #data do
will have consistent ordering in the elements, since they are just stored as subsequent indices that increment from 1, before and after loading.{ Test = {...}, Value = 2, Pets = {...}, Items = {...}, Message = "Hello!" }
for ... in pairs(data) do
loop, the ordering is not defined. So you might see the order in which the string keys are traversed to be different when you loop over them before saving and after loading.Note: doing a pairs-loop over an array also has undefined ordering technically speaking, so make sure to do the for i = 1, #data do
variant if you need consistent order of traversal.