diff --git a/GUI/Controls/ManageMods.cs b/GUI/Controls/ManageMods.cs index 4c256aca94..76eb2492a1 100644 --- a/GUI/Controls/ManageMods.cs +++ b/GUI/Controls/ManageMods.cs @@ -1246,6 +1246,15 @@ private int CompareRows(DataGridViewRow a, DataGridViewRow b) return CompareColumn(a, b, ModName); } + /// + /// Compare two rows based on one of their columns + /// + /// First row + /// Second row + /// The column to compare + /// + /// -1 if a<b, 1 if a>b, 0 if a==b + /// private int CompareColumn(DataGridViewRow a, DataGridViewRow b, DataGridViewColumn col) { GUIMod gmodA = a.Tag as GUIMod; @@ -1256,15 +1265,21 @@ private int CompareColumn(DataGridViewRow a, DataGridViewRow b, DataGridViewColu var cellB = b.Cells[col.Index]; if (col is DataGridViewCheckBoxColumn cbcol) { + // Checked < non-"-" text < unchecked < "-" text if (cellA is DataGridViewCheckBoxCell checkboxA) { return cellB is DataGridViewCheckBoxCell checkboxB - ? -((bool)checkboxA.Value).CompareTo((bool)checkboxB.Value) - : -1; + ? -((bool)checkboxA.Value).CompareTo((bool)checkboxB.Value) + : (bool)checkboxA.Value || ((string)cellB.Value == "-") ? -1 + : 1; } else { - return cellB is DataGridViewCheckBoxCell ? 1: 0; + return cellB is DataGridViewCheckBoxCell ? -CompareColumn(b, a, col) + : (string)cellA.Value == (string)cellB.Value ? 0 + : (string)cellA.Value == "-" ? 1 + : (string)cellB.Value == "-" ? -1 + : ((string)cellA.Value).CompareTo((string)cellB.Value); } } else