title: Sorting Dictionary with child dictionary of object value type
body: <p>I have a <code>Dictionary&lt;string, Dictionary&lt;string, object&gt;&gt;</code> that needs to be sorted depending on a certain value of the child dictionary.</p>
  <p>e.g</p>
  <pre><code>{
    &quot;James&quot;: {
      &quot;Age&quot;:  21,
      &quot;Surname&quot;: &quot;Doe&quot;,
      &quot;Temp&quot;: 80.6
    },
    &quot;Tobi&quot;: {
      &quot;Age&quot;:  26,
      &quot;Surname&quot;: &quot;Doe&quot;,
      &quot;Temp&quot;: 60.5
    }
  }
  </code></pre>
  <p>The dictionary with key James and Tobi needs to be sorted depending on i.e.  the temp value.
  The string &quot;Temp&quot; would be given to the method to indicate the key to be sorted on.</p>
  <p>The object values type would differ depending on the context but the type would be known to the method allowing to cats the object to the correct type for comparison.</p>
  <p>Creating a specific object would not be possible for the solution as dictionary&lt;string, object&gt; represents the object properties and would differ with each implementation of the method.</p>
  <p>All child dictionaries would have the same &quot;properties&quot; so the child dictionary not having the value would not be a problem.</p>
  <p>so in plain description, a method taking in:</p>
  <pre><code>{
    &quot;James&quot;: {
      &quot;Age&quot;:  21,
      &quot;Surname&quot;: &quot;Doe&quot;,
      &quot;Temp&quot;: 80.6
    },
    &quot;Tobi&quot;: {
      &quot;Age&quot;:  26,
      &quot;Surname&quot;: &quot;Doe&quot;,
      &quot;Temp&quot;: 60.5
    },
    &quot;Jessica&quot;: {
      &quot;Age&quot;:  18,
      &quot;Surname&quot;: &quot;Samms&quot;,
      &quot;Temp&quot;: 50.67
    }
  }
  </code></pre>
  <p>and</p>
  <p>string &quot;Temp&quot;</p>
  <p>and posibily Temp type of</p>
  <p>string &quot;double&quot;</p>
  <p>that returns</p>
  <p><code>IEnumerable&lt;KeyValuePair&lt;string,Dictionary&lt;string,object&gt;&gt;&gt;</code></p>
  <pre><code>{
    &quot;Jessica&quot;: {
      &quot;Age&quot;:  18,
      &quot;Surname&quot;: &quot;Samms&quot;,
      &quot;Temp&quot;: 50.67
    },
    &quot;Tobi&quot;: {
      &quot;Age&quot;:  26,
      &quot;Surname&quot;: &quot;Doe&quot;,
      &quot;Temp&quot;: 60.5
    },
    &quot;James&quot;: {
      &quot;Age&quot;:  21,
      &quot;Surname&quot;: &quot;Doe&quot;,
      &quot;Temp&quot;: 80.6
    }
  }
  </code></pre>