nodes: 0, module; 1, function_definition; 2, function_name:check_sorted; 3, parameters; 4, block; 5, identifier:cards; 6, default_parameter; 7, expression_statement; 8, expression_statement; 9, expression_statement; 10, if_statement; 11, identifier:ranks; 12, None; 13, comment:"""
      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``.
  
      """; 14, assignment; 15, assignment; 16, boolean_operator; 17, block; 18, else_clause; 19, identifier:ranks; 20, boolean_operator; 21, identifier:sorted_cards; 22, call; 23, comparison_operator:cards == sorted_cards; 24, comparison_operator:cards[::-1] == sorted_cards; 25, return_statement; 26, block; 27, identifier:ranks; 28, identifier:DEFAULT_RANKS; 29, identifier:sort_cards; 30, argument_list; 31, identifier:cards; 32, identifier:sorted_cards; 33, subscript; 34, identifier:sorted_cards; 35, True; 36, return_statement; 37, identifier:cards; 38, identifier:ranks; 39, identifier:cards; 40, slice; 41, False; 42, unary_operator; 43, integer:1
code: 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