title: ObservableCollection Sort extension method on key
body: <p>Hi I have an <code>ObservableCollection</code> in which where I add an item, I want to sort it. </p>
  
  <p>I want to sort it on a key so for example:</p>
  
  <pre><code>collection.OrderByDescending(x =&gt; x.property)
  </code></pre>
  
  <p>I have created an extension method that will sort when the item is added too (<code>.Add</code>), however, the extension method needs to do something like the above code. Using the code from the extension method below, can someone help me?</p>
  
  <pre><code>public static void Sort&lt;T&gt;(this ObservableCollection&lt;T&gt; collection) where T : IComparable
  {
     List&lt;T&gt; sorted = collection.OrderByDescending(x =&gt; x).ToList();
     for (int i = 0; i &lt; sorted.Count(); i++)
          collection.Move(collection.IndexOf(sorted[i]), i);
  }
  </code></pre>
  
  <p>Also does the generic really need to implement the <code>IComparable</code> interface? (I am very new to extension methods).</p>