nodes: 0, module; 1, function_definition; 2, function_name:sort_cards; 3, parameters; 4, block; 5, identifier:cards; 6, default_parameter; 7, expression_statement; 8, expression_statement; 9, if_statement; 10, if_statement; 11, return_statement; 12, identifier:ranks; 13, None; 14, comment:"""
      Sorts a given list of cards, either by poker ranks, or big two ranks.
  
      :arg cards:
          The cards to sort.
      :arg dict ranks:
          The rank dict to reference for sorting. If ``None``, it will
          default to ``DEFAULT_RANKS``.
  
      :returns:
          The sorted cards.
  
      """; 15, assignment; 16, call; 17, block; 18, call; 19, block; 20, identifier:cards; 21, identifier:ranks; 22, boolean_operator; 23, attribute; 24, argument_list; 25, expression_statement; 26, attribute; 27, argument_list; 28, expression_statement; 29, identifier:ranks; 30, identifier:DEFAULT_RANKS; 31, identifier:ranks; 32, identifier:get; 33, string:"suits"; 34, assignment; 35, identifier:ranks; 36, identifier:get; 37, string:"values"; 38, assignment; 39, identifier:cards; 40, call; 41, identifier:cards; 42, call; 43, identifier:sorted; 44, argument_list; 45, identifier:sorted; 46, argument_list; 47, identifier:cards; 48, keyword_argument; 49, identifier:cards; 50, keyword_argument; 51, identifier:key; 52, lambda; 53, identifier:key; 54, lambda; 55, lambda_parameters; 56, conditional_expression:ranks["suits"][x.suit] if x.suit != None else 0; 57, lambda_parameters; 58, subscript; 59, identifier:x; 60, subscript; 61, comparison_operator:x.suit != None; 62, integer:0; 63, identifier:x; 64, subscript; 65, attribute; 66, subscript; 67, attribute; 68, attribute; 69, None; 70, identifier:ranks; 71, string:"values"; 72, identifier:x; 73, identifier:value; 74, identifier:ranks; 75, string:"suits"; 76, identifier:x; 77, identifier:suit; 78, identifier:x; 79, identifier:suit
code: def sort_cards(cards, ranks=None):
      """
      Sorts a given list of cards, either by poker ranks, or big two ranks.
  
      :arg cards:
          The cards to sort.
      :arg dict ranks:
          The rank dict to reference for sorting. If ``None``, it will
          default to ``DEFAULT_RANKS``.
  
      :returns:
          The sorted cards.
  
      """
      ranks = ranks or DEFAULT_RANKS
  
      if ranks.get("suits"):
          cards = sorted(
              cards,
              key=lambda x: ranks["suits"][x.suit] if x.suit != None else 0
          )
      if ranks.get("values"):
          cards = sorted(
              cards,
              key=lambda x: ranks["values"][x.value]
          )
  
      return cards