def check_satisfaction_criteria(shards):
    """check_satisfaction_criteria(shards)

    Given an interable collection of shards, this function determines
    both which of the group member thresholds have been satisfied by
    the selecton and whether the overall group threshold has been met.
    This function returns a pair of elements, the first item is a boolean
    representing whether or not the overall group threshold is met and the
    second is a set of group indexes whose thresholds have been met.
    """
    groups = {}
    filled = set()
    satisfied = False
    for s in shards:
        group_idx, _ = s.shard_id
        if not group_idx in groups:
            groups[group_idx] = 0
        groups[group_idx] += 1
        if groups[group_idx] >= s.member_threshold:
            filled.add(group_idx)
        satisfied = len(filled) >= s.group_threshold
    return satisfied, filled
