diff --git a/Maui.DataGrid.Sample/Models/Team.cs b/Maui.DataGrid.Sample/Models/Team.cs index 4d2a6b7..6530bfe 100644 --- a/Maui.DataGrid.Sample/Models/Team.cs +++ b/Maui.DataGrid.Sample/Models/Team.cs @@ -22,14 +22,20 @@ public class Streak : IComparable public int CompareTo(object? obj) { - var score = Result == Result.Won ? NumStreak : -NumStreak; if (obj is Streak s) { - var otherScore = s.Result == Result.Won ? s.NumStreak : -s.NumStreak; - return score - otherScore; + // First compare the Result + var resultComparison = Result.CompareTo(s.Result); + if (resultComparison != 0) + { + return resultComparison; + } + + // If Result is the same, then compare the NumStreak + return NumStreak.CompareTo(s.NumStreak); } - return score; + throw new ArgumentException("Object is not a Streak"); } ///