Dictionary value order saved in .tres

Godot Version



When saving a dictionary (in a Resource class) to .tres file, the key and values’ order will automatically be key’s letter order (1-9,a-z,…), is that a specific design?

If true, do I need to save the original order in another int: uuid dictionary to keep the order?

Step 1: see the position of that data

Step 2: the data changed its position after I save it…

Dictionaries are not guaranteed to be in any particular order. If you want to keep the order what you can do is make a dictionary of dictionaries where the key is whatever and the value is a dictionary, then that inner one has your data AND an order value that you can later use to sort with.
Like {"my_name": {"order": 0, "color": ..., "place": ...}} something like that.

1 Like

ok thx!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.