title: Determine whether an IQueryable<T> has been ordered or not
body: <p>Is there a way to know if an <code>IQueryable&lt;T&gt;</code> has been ordered (using <code>OrderBy</code> or <code>OrderbyDescending</code>)?</p>
  
  <p>So I know whether to call <code>OrderBy</code> or <code>ThenBy</code> on the collection.</p>
  
  <pre><code>IQueryable&lt;Contact&gt; contacts = Database.GetContacts();
  </code></pre>
  
  <p>I tried <code>contacts is IOrderedQueryable&lt;Contact&gt;</code>, but it's always true.</p>
  
  <p><strong>Edit</strong>: I just changed my example, the previous one wasn't really showing my point. Assume that <code>GetContacts</code> uses Entity Framework and simply returns all the records of a table.</p>
  
  <p>Later on, I apply several functions to <code>contacts</code>, I have no knowledge of what those functions do. They can sort or filter the <code>IQueryable&lt;Contact&gt;</code>.</p>
  
  <p>When I get the collection back, I need to sort it once more. To do so, I need to know whether I need to call <code>OrderBy</code>, or <code>ThenBy</code>. So I don't reorder the whole collection if it has already been sorted.</p>