public override int CompareTo(AcPlaceholderNew o) { var c = o as CarSetupObject; if (c == null) { return(base.CompareTo(o)); } var lhsEnabled = Enabled; if (lhsEnabled != c.Enabled) { return(lhsEnabled ? -1 : 1); } var lhsParent = TrackId; var rhsParent = c.TrackId; if (lhsParent == null && rhsParent == null || lhsParent == rhsParent) { return(DisplayName.InvariantCompareTo(c.DisplayName)); } return(lhsParent.InvariantCompareTo(rhsParent)); }