def compare_stacks(cards_x, cards_y, sorted=False):
    """
    Checks whether two given ``Stack``, ``Deck``, or ``list`` instances,
    contain the same cards (based on value & suit, not instance). Does not
    take into account the ordering.

    :arg cards_x:
        The first stack to check. Can be a ``Stack``, ``Deck``, or ``list``
        instance.
    :arg cards_y:
        The second stack to check. Can be a ``Stack``, ``Deck``, or ``list``
        instance.
    :arg bool sorted:
        Whether or not the cards are already sorted. If ``True``, then
        ``compare_stacks`` will skip the sorting process.

    :returns:
        ``True`` or ``False``.

    """
    if len(cards_x) == len(cards_y):
        if not sorted:
            cards_x = sort_cards(cards_x, DEFAULT_RANKS)
            cards_y = sort_cards(cards_y, DEFAULT_RANKS)
        for i, c in enumerate(cards_x):
            if c != cards_y[i]:
                return False
        return True
    else:
        return False
Checks whether two given ``Stack``, ``Deck``, or ``list`` instances,
    contain the same cards (based on value & suit, not instance). Does not
    take into account the ordering.

    :arg cards_x:
        The first stack to check. Can be a ``Stack``, ``Deck``, or ``list``
        instance.
    :arg cards_y:
        The second stack to check. Can be a ``Stack``, ``Deck``, or ``list``
        instance.
    :arg bool sorted:
        Whether or not the cards are already sorted. If ``True``, then
        ``compare_stacks`` will skip the sorting process.

    :returns:
        ``True`` or ``False``.