def linkage_group_ordering(linkage_records):
    new_records = dict()
    for lg_name, linkage_group in itertools.groupby(
        linkage_records, operator.itemgetter(0)
    ):
        new_records[lg_name] = []
        for record in linkage_group:
            init_contig = record[-1]
            start = record[1]
            end = record[2]
            new_record = [init_contig, -3, start, end, 1]
            new_records[lg_name].append(new_record)
    return new_records