title: IQueryable/Linq Orderby Fail: Sorts only a limited number of records
body: <p>I have a an application that handles hundreds of records at a time and I use the following code to order the query but it will sort and order only a limited number of records.</p>
  
  <pre><code>switch (sortOrder)
  {
  case "created":
      folders = (from f in folders orderby f.created_date ascending select f);
  
      //folders = folders.OrderBy(f =&gt; f.created_date.Value.Year)
      //                .ThenBy(f =&gt; f.created_date.Value.Month)
      //                .ThenBy(f =&gt; f.created_date.Value.Day);
      break;
  case "created_desc":
      folders = (from f in folders orderby f.created_date descending select f);
  
      //folders = folders.OrderByDescending(f =&gt; f.created_date.Value.Year)
      //                    .ThenByDescending(f =&gt; f.created_date.Value.Month)
      //                    .ThenByDescending(f =&gt; f.created_date.Value.Day);
      break;
  default:
      folders = folders.OrderBy(f =&gt; f.folder_number);
      break;
  }
  </code></pre>
  
  <p>Additionally, when I try to sort it multiple times: ascending, descending then ascending again, it won't sort past the first ascending sort. If that makes sense. So it'll sort fine for the first 20 or so records, but then when you continue to scroll down, you can see that all of the records were not sorted properly. I've tried IQueryable and Linq and both produces the same results.</p>
  
  <p><a href="https://i.stack.imgur.com/w3Osw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/w3Osw.png" alt="Sort by Create Date img1"></a></p>
  
  <p><a href="https://i.stack.imgur.com/QRiNo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QRiNo.png" alt="Sort by Create Date img2"></a></p>