namespace Content.Client.UserInterface.Controls; /// /// A class to compare radial menu options. /// Orders options in ascending order (null last!), then alphabetical tooltip (null last!). /// public sealed class RadialMenuOptionComparer : IComparer { /// /// Compares two RadialMenuOptionBase. /// /// public int Compare(RadialMenuOptionBase? x, RadialMenuOptionBase? y) { if (ReferenceEquals(x, y)) return 0; if (y == null) return -1; if (x == null) return 1; // First sort by order, then by tooltip. // Any non-null order value comes before null. if (y.Order != x.Order) { if (y?.Order is null) return -1; if (x?.Order is null) return 1; return x.Order < y.Order ? -1 : 1; } // Sort by tooltip: non-null order values come before null ones. if (y?.ToolTip is null) return -1; if (x?.ToolTip is null) return 1; return string.Compare(x.ToolTip, y.ToolTip, StringComparison.Ordinal); } }