title: How to sort nested dictionaries in TCL
body: <p>I have a nested dictionary in TCL where the values at a particular index are unsorted at a subindex value, for example in this dictionary, I want to sort 55,21,36 and move the subkeys while sorting, and I also want to sort 103,344,3 while moving around their subkeys as well</p>
  
  <p>I am very confused how one goes about doing something like this. I cannot use lsort -index -stride since my sub Dictionary isn't a single flattened list</p>
  
  <pre><code>a1,a2 {0,6 {103 55} 1,5 {344 21} 6,7 {3 36}}
  </code></pre>
  
  <p>Expected Output 1 [Sort based on 21,36,55 [final subvalues], 55 goes all the way towards the end with its key]</p>
  
  <pre><code>a1,a2 {1,5 {344 21} 6,7 {3 36} 0,6 {103 55}}
  </code></pre>
  
  <p>Expected Output 2 [Sort based on 344,3,103, 344 goes all the way towards the end along with its key]</p>
  
  <pre><code>a1,a2 {6,7 {3 36} 0,6 {103 55} 1,5 {344 21}}
  </code></pre>