How to sort a dictionary by key names

I couldn’t find a similar answer for my case.
I have this dictionary:

["_003_005"] =    {
    ["Out"] =    {
          ["_003_006"] = 3
          ["_002_005"] = 3
    },
    ["In"] =    {
          ["_003_004"] = 3
    }
},
["_004_004"] =    {
    ["Out"] =    {
          ["_003_004"] = 3
    },
    ["In"] =    {
          ["_005_004"] = 3
    }
},
["_003_003"] =    {
    ["Out"] =    {
          ["_004_003"] = 3,
          ["_002_003"] = 2,
          ["_003_004"] = 0
    },
    ["In"] =    {
          ["_003_002"] = 2
    }
},

I need to sort it by the key names, so it should appear like this:

["_003_003"] =    {
    ["In"] =    {
          ["_003_002"] = 2
    }
    ["Out"] =    {
          ["_002_003"] = 2,
          ["_003_004"] = 0
          ["_004_003"] = 3,
    },
},
["_003_005"] =    {
    ["In"] =    {
          ["_003_004"] = 3
    }
    ["Out"] =    {
          ["_002_005"] = 3
          ["_003_006"] = 3
    },
},
["_004_004"] =    {
    ["In"] =    {
          ["_005_004"] = 3
    }
    ["Out"] =    {
          ["_003_004"] = 3
    },
},

The keys in all levels are sorted.

How could I get the result above?

1 Like

You would have to make your own custom iterator.