<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def check_sorted(cards, ranks=None):
 """ Checks whether the given cards are sorted by the given ranks. :arg cards: The cards to check. Can be a ``Stack``, ``Deck``, or ``list`` of ``Card`` isntances. :arg dict ranks: The ranks to check against. Default is DEFAULT_RANKS. :returns: ``True`` or ``False``. """

    ranks = ranks or DEFAULT_RANKS

    sorted_cards = sort_cards(cards, ranks)

    if cards == sorted_cards or cards[::-1] == sorted_cards:
        return True
    else:
        return False