rankCards function

void rankCards (
  1. List<CreditCard> cards,
  2. ShoppingCategory category
)

Implementation

void rankCards(List<CreditCard> cards, ShoppingCategory category) {
  cards.sort((CreditCard cardLhs, CreditCard cardRhs) {
    double maxLhsRate = getMaxRate(cardLhs, category);
    double maxRhsRate = getMaxRate(cardRhs, category);
    return maxRhsRate.compareTo(maxLhsRate);
  });
}