🧐 Why Doesn't My Dictionary in Dynamo Keep Key Order, and How Can I Fix It for the Dynamo Player?

I’m using the Dictionary.ByKeysValues node in Dynamo to combine a list of string keys and a list of values. My intention is to display the result in an ordered manner in the Dynamo Player (by marking the Watch node as an output).

As you can see in the attached image , I connected my keys in the order:

  1. ā€œError en la entrada Nro. 3 (BORDES COMPLEJOS)ā€
  2. ā€œHora Inicialā€
  3. ā€œHora Finalā€
  4. ā€œTiempo Total de ejecuciónā€

However, the resulting dictionary in the node’s output and in the Dynamo Player is shown with the keys out of order (for example: ā€œ2. Hora Inicialā€, ā€œ4. Tiempo Total de ejecuciónā€, ā€œ3. Hora Finalā€, ā€œ1. Errorā€¦ā€).

I tried using an OrderedDict inside a Python Script node, but when trying to pass it as an output to Dynamo or the Player, it seems the Dynamo Dictionary still isn’t an ordered data type, or the Player handles it as a standard dictionary.

My questions are:

  1. Why does this lack of order occur? (I understand that dictionaries are, by definition, unordered collections in Dynamo and in many Python implementations, although modern Python keeps them ordered, Dynamo seems not to).
  2. Is there any way to force the order of the dictionary so that the output in the Dynamo Player displays the keys in the same order I originally provided them?
  3. If a dictionary cannot be used, what would be the best alternative to display this grouped and ordered information in the Dynamo Player?

The goal is to have a final output in the Dynamo Player where the labels (keys) and the corresponding values are displayed logically and sequentially.

Any help or explanation on how Dynamo handles this would be greatly appreciated!

Any language which adds sorting to the displayed order of a dictionary is adding a non-trivial amount of computational overhead. Dynamo skips that to keep the speed.

No - you would have to move to a non-dictionary format.

A list of strings should work. Something like this where keys is the ordered list of keys and yourDictionary is the dictionary with it’s key:value pairs. keys+yourDictionary[keys]