public int CompareTo(object obj) { if (!(obj is ScoreboardEntry)) { throw new Exception("Bad object comparison"); } if (obj == null) { return(1); } var toCompare = obj as ScoreboardEntry; if (Points > toCompare.Points) { return(1); } else if (Points < toCompare.Points) { return(-1); } if (MinesOwned > toCompare.MinesOwned) { return(1); } else if (MinesOwned < toCompare.MinesOwned) { return(-1); } return(PlayerName.CompareTo(toCompare.PlayerName)); }