namespace ProjectElectroTrans.Drawnings; public class DrawingTransCompareByType : IComparer { public int Compare(DrawingTrans? x, DrawingTrans? y) { if (x == null && y == null) return 0; if (x == null || x.EntityTrans == null) { return 1; } if (y == null || y.EntityTrans == null) { return -1; } if (x.GetType().Name != y.GetType().Name) { return x.GetType().Name.CompareTo(y.GetType().Name); } var speedCompare = x.EntityTrans.Speed.CompareTo(y.EntityTrans.Speed); if (speedCompare != 0) { return speedCompare; } return x.EntityTrans.Weight.CompareTo(y.EntityTrans.Weight); } }