from typing import Counter
from typing import Tuple
from typing import List


def order_counts(counts: Counter[Tuple[int, ...]]) -> List[int]:
    """
    Helper method for organising two-qubit correlations.
    :param counts: Counter object as returned by BackendResult, giving two qubit counts for desired correlation
    :type counts: Counter[Tuple[int, ...]]

    :return: A four element list, giving counts for the (0,0), (0,1), (1,0) and (1,1) states in order.
    :rtype: List[int]
    """
    ordered_counts = [0, 0, 0, 0]
    if (0, 0) in counts:
        ordered_counts[0] = counts[(0, 0)]
    if (0, 1) in counts:
        ordered_counts[1] = counts[(0, 1)]
    if (1, 0) in counts:
        ordered_counts[2] = counts[(1, 0)]
    if (1, 1) in counts:
        ordered_counts[3] = counts[(1, 1)]
    return ordered_counts