def get_best(records):
    """Given a set of records, return the "best" one.
    "best" considers the source of the record, preferring MCDW over
    USHCN over SUMOFDAY over UNKNOWN.

    (this is passed to do_combine() as a select_func argument)
    """
    ranks = {'MCDW': 4, 'USHCN2': 3, 'SUMOFDAY': 2, 'UNKNOWN': 1}
    best = 1
    longest = 0
    for record in sorted(records, key=lambda r: r.uid):
        length = record.ann_anoms_good_count()
        rank = ranks[record.source]
        if rank > best:
            best = rank
            best_rec = record
        elif length > longest:
            longest = length
            longest_rec = record
    if best > 1:
        return best_rec
    return longest_rec
