title: How to order list based on another list
body: <p>I have a list <code>List&lt;T&gt; ListT</code> of custom object type<code>&lt;T&gt;</code>. </p>
  
  <p>Now there are two items in the list, one with <code>ID = 1089</code> and another with <code>ID = 1090</code></p>
  
  <p>Based on some logic, I will sort <code>ListT</code>using following way:</p>
  
  <pre><code>ListT = ListT.OrderByDescending(x=&gt;x.Order.HasValue).ThenBy(x=&gt;x.Order).ToList();
  </code></pre>
  
  <p>After the above query, <code>ListT</code> will now have <code>ID = 1090</code> be the first item and <code>ID = 1089</code> as second item.</p>
  
  <p>Now I will retrieve another new list, <code>ListB</code> from database. The sample data would be as below:</p>
  
  <p><img src="https://i.stack.imgur.com/7S6tm.png" alt="enter image description here"></p>
  
  <p>My objective is to rearrange <code>ListB</code> so that the order of <code>ID</code> in <code>ListB</code> following the order of <code>ID</code> in <code>ListT</code>, and after that, rearrange <code>ListB</code> so that it would following the <code>Order</code> value in ascending order.</p>
  
  <p>In the end, the expected result should be:</p>
  
  <p><img src="https://i.stack.imgur.com/Txne7.png" alt="enter image description here"></p>