title: How can I sort a TCL array based on the values of its keys?
body: <p>The <code>INITIAL_ARRAY</code> is</p>
  
  <pre><code>Key -&gt; Value
  B      8
  C     10
  A      5
  E      3
  D      1
  </code></pre>
  
  <p>To get a sorted array based on key,  I use</p>
  
  <pre><code>set sorted_keys_array [lsort [array names INITIAL_ARRAY]]
  </code></pre>
  
  <p>to get the output</p>
  
  <pre><code>Key -&gt; Value
  A     5
  B     8
  C     10
  D     1
  E     3
  </code></pre>
  
  <p>Like wise, how to get a sorted  tcl array based on <strong>values</strong> of keys, like output  below?</p>
  
  <pre><code>Key -&gt; Value
   C     10
   B     8 
   A     5
   E     3
   D     1
  </code></pre>