I've got a base class GraphUIControl which is inherited by 4 child classes:BubbleGraphUIControlBatchGraphUIControlLineGraphUIControlStackedGraphUIControlI sometimes put all my GraphUIControl in the same List<GraphUIControl> for some obscure reasons.I wanted to order my list (first by Graph type, then by name) so I implemented my custom iComparer:public class GraphUIControlComparer : IComparer<GraphUIControl>{    public int Compare(GraphUIControl x, GraphUIControl y)    {        if (x.GetType() == y.GetType())        {            return String.Compare(x.Parent.Name, y.Parent.Name, StringComparison.Ordinal);        }        if (x is BubbleGraphUIControl)        {            return -1;        }        if (y is BubbleGraphUIControl)        {            return 1;        }        if (x is BatchGraphUIControl)        {            return -1;        }        if (y is BatchGraphUIControl)        {            return 1;        }        if (x is LineGraphUIControl)        {            return -1;        }        if (y is LineGraphUIControl)        {            return 1;        }        if (x is StackedGraphUIControl)        {            return -1;        }        if (y is StackedGraphUIControl)        {            return 1;        }               return 0;    }}But it seems very verbose and I'd love to make it shorter (also, as it's my first iComparer, if I made a mistake/nonsense/whatever, don't hesitate to tell me!)Example:Let's take A, A1, A2, B & C as :A is a BubblueGraphUIControlA1 is a BubblueGraphUIControlA2 is a BubblueGraphUIControlC is a LineGraphUIControlB is a StackedGraphUIControlI put it in the list named myList in random mode. When I do myList.Sort(new GraphUIControlComparer()) I want myList to be in the order A, A1, A2, C, B because of the types order following this rule:BubbleGraphUIControlBatchGraphUIControlLineGraphUIControlStackedGraphUIControlThen the A, A1, A2 are in alphabetic order.
Custom iComparer
c#;sorting