public int Compare(object obj1, object obj2) { Type t1 = obj1 as Type; Type t2 = obj2 as Type; // these are used to group by (for example all enums together) TypeGroup t1Group = TypeComparer.GetGroupForType(t1); TypeGroup t2Group = TypeComparer.GetGroupForType(t2); if (t2Group != t1Group) { return(((int)t1Group) < ((int)t2Group) ? -1 : 1); } return(t1.Name.CompareTo(t2.Name)); }