def _pick_tcga_submitter(a, b):
    """Comparator function for barcodes, using the rules described in the GDAC                                                     
    FAQ entry for replicate samples: https://confluence.broadinstitute.org/display/GDAC/FAQ                                        
    """
    analyte1 = a[19]
    analyte2 = b[19]
    plate1 = a[21:25]
    plate2 = b[21:25]
    if a == b:
        return a
    elif analyte1 == analyte2:
        return a if a >= b else b
    elif analyte1 == 'H':
        return a
    elif analyte1 == 'R':
        return a if analyte2 == 'T' else b
    elif analyte1 == 'T':
        return b
    elif analyte1 == 'D':
        return a if plate2 <= plate1 else b
    elif analyte2 == 'D':
        return b if plate1 <= plate2 else a
    else:
        return a if a >= b else b
