public int CompareTo(ComparableReportCards other) { if (string.IsNullOrEmpty(CardsString) || string.IsNullOrEmpty(other.CardsString)) { if (string.IsNullOrEmpty(CardsString) && string.IsNullOrEmpty(other.CardsString)) { return(0); } else if (string.IsNullOrEmpty(CardsString)) { return(-1); } else { return(1); } } if (CardsString.Length >= 2 && other.CardsString.Length >= 2) { for (int i = 0; i < 2; i++) { int result = CardHelper.GetCardRank(CardsString[i].ToString()) - CardHelper.GetCardRank(other.CardsString[i].ToString()); if (result != 0) { return(result); } } } return(CardsString.Length - other.CardsString.Length); }