title: Linq: Dictionary - OrderBy with preference Dictionary
body: <p>I am refering to this (<a href="https://stackoverflow.com/questions/728319/linq-orderby-against-specific-values/728910#728910">Linq OrderBy against specific values</a>) question:</p>
  
  <p>I want to sort a Dictionary with very few values suiting my needs. There will only be 6 entries with keys that should be sorted after my custom logic. I am thinking about one data-dictionary and one pref-dictionary:</p>
  
  <pre><code>Dictionary&lt;string, int&gt; data = new Dictionary&lt;string,int&gt;() {
          {"Test16", 10},
          {"What61", 8}, 
          {"Blub11", 14},
          {"Int64", 13}
      };
  
  Dictionary&lt;string, int&gt; preferences = new Dictionary&lt;string, int&gt;() {
          {"Blub11", 1},
          {"What61", 2},
          {"Int64", 3},
          {"Test16", 4}
      };
  
  // desired Output:
  // data =
  //  {"Blub11", 14},
  //  {"What61", 8},
  //  {"Int64", 13},
  //  {"Test16", 10}
  
  string key;
  data = data.OrderBy(
      item =&gt; preferences.TryGetValue(item, out key) ? data[key] : item
  );
  </code></pre>
  
  <p>I can't get this to work and must admit that I am not familiar with lambda expressions and linq so a simple solution would be appreciated. Thank you so far.</p>