title: How to sort a dictionary in the same order of another dictionary in c#
body: <p>I have two dictionary one composed by:</p>
  
  <p>1) <code>&lt;Id, Name&gt;</code> </p>
  
  <p>This dictionaryis sorted by "Name"</p>
  
  <p>Another dictionary composed by:</p>
  
  <p>2) <code>&lt;Id, ListOfValues&gt;</code></p>
  
  <p>This dictionary`is not sorted.</p>
  
  <p>I have to sort the second dictionary in the same order of the first, i can use Id as common point, how i can do this?</p>
  
  <p>How i can sort the second dictionary </p>
  
  <pre><code>String json = data as string;
  var rawData = JsonConvert.DeserializeObject&lt;List&lt;SectionItem&gt;&gt;(json);
  
  /* New dictionary used to order item for name */ 
  Dictionary&lt;string, string&gt; dataToOrder = new Dictionary&lt;string, string&gt;();
  var name ="";
  /* Getting data in "local language" */
  var local_lang = ConfigurationContext.CurrentLocale;
  
  /* In dataToOrder I insert name and Id*/
  foreach (SectionItem si in rawData)
  {
        name = si.Entities[local_lang].Name;
        dataToOrder.Add(name, si.Id);
  }
  
  /* List with ordered data by name*/
  var orderedData = dataToOrder.OrderBy(kvp =&gt; kvp.Key).ToList();
  </code></pre>
  
  <p>Now I have to order each element of rawdata in the same order of orderedData , how i can do this ?</p>
  
  <pre><code>public class SectionItem
  {
      public string Id;
      public Dictionary&lt;string, EntityGroup&gt; Entities;
  }
  </code></pre>