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