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
def sort_card_indices ( cards , indices , ranks = None ) : 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
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.