def sort_by_lineage(records, callback=None):
    """
    Resolve stream into a dictionary keyed by Pangolin lineage

    :param records:  generator, return value of extract_features()
    :return:  dict, lists of records keyed by lineage
    """
    result = {}
    for i, record in enumerate(records):
        if callback and i % 1000 == 0:
            callback('aligned {} records'.format(i))
        lineage = record['covv_lineage']
        if lineage not in result:
            result.update({lineage: []})
        result[lineage].append(record)
    return result