title: How to order, grouped linq query by getting summation of element in each group c#
body: <p>I have an entity i would say it as "Items",
  Structure of this entity like below,</p>
  
  <pre><code>string itemName
  int groupId
  decimal itemPrice
  int itemQty
  </code></pre>
  
  <p>first i wanted to group it by <code>groupId</code> and return it as a list of list of items (<code>List&lt;List&lt;Items&gt;&gt;</code>)
  I followed this instruction and successfully did it. <a href="https://stackoverflow.com/questions/2697253/using-linq-to-group-a-list-of-objects-into-a-new-grouped-list-of-list-of-objects">Using Linq to group a list of objects into a new grouped list of list of objects</a></p>
  
  <p>Here is my code to get that <code>List&lt;List&lt;Item&gt;&gt;</code></p>
  
  <pre><code>var groupedItem = rawItemData               
          .GroupBy(u =&gt; u.groupId)             
          .Select(grp =&gt; grp.ToList())          
          .ToList();
  </code></pre>
  
  <p>But now i want to order each group(list) by getting summation of itemPrice on it.  </p>
  
  <p>Example for my expectation:</p>
  
  <ul>
  <li>1st element of my result has 5 Items, Summation of item price in this group is 350</li>
  <li>2nd element of my result has 10 Items, Summation of item price in this group is 500</li>
  <li>3rd element of my result has 2 Items, Summation of item price in this group is 150</li>
  <li>4th element of my result has 6 Items, Summation of item price in this group is 555 </li>
  </ul>
  
  <p>I want to group my main result by this summation of item price,</p>
  
  <p>Expected order is like below,
  4th element, 2nd element, 1st element, 3rd element.</p>
  
  <p>Something very hard to explain, Please let me know if need more clarification on this question.</p>
  
  <p>Thank you very much!</p>