Custom Sort of ObservableCollection<T> with base type <p>I have the following simplified classes:</p> <pre><code>public class BaseContainer { public BaseContainer() { Children = new ObservableCollection&lt;BaseContainer&gt;(); } public ObservableCollection&lt;BaseContainer&gt; Children { get; set; } } public class ItemA : BaseContainer { public ItemA() { base.Children.Add(new ItemB() { ItemBName = "bb" }); base.Children.Add(new ItemA() { ItemAName = "ab" }); base.Children.Add(new ItemB() { ItemBName = "ba" }); base.Children.Add(new ItemA() { ItemAName = "aa" }); } public string ItemAName { get; set; } } public class ItemB : BaseContainer { public string ItemBName { get; set; } } </code></pre> <p>I'm trying to sort my ItemA.Children collection based on two conditions:</p> <ol> <li>All Item A's must come first in the collection</li> <li>Item A's should be sorted by ItemAName</li> <li>Item B's should be sorted by ItemBName</li> </ol> <p>So after sorting I'd expect something like this:</p> <ul> <li>ItemA - ItemAName = "aa"</li> <li>ItemA - ItemAName = "ab"</li> <li>ItemB - ItemBName = "ba"</li> <li>ItemB - ItemBName = "bb"</li> </ul> <p>Any ideas on how to accomplish this?</p> <p>I was able to sort by class type name:</p> <pre><code> List&lt;BaseContainer&gt; temp = base.Children.ToList(); temp.Sort((x, y) =&gt; string.Compare(x.GetType().Name, y.GetType().Name)); base.Children.Clear(); base.Children.AddRange(temp); </code></pre> <p>But Names are not sorted...</p> <p>Thanks!</p>