def METHOD_NAME(records, read_lengths):
    sorted_records = sorted(map(itemgetter('tile', 'cycle', 'error_rate'),
                                records))
    max_forward_cycle = read_lengths and read_lengths[0] or sys.maxsize
    min_reverse_cycle = read_lengths and sum(read_lengths[:-1])+1 or sys.maxsize
    for record in sorted_records:
        cycle = record[1]
        if cycle >= min_reverse_cycle:
            cycle = min_reverse_cycle - cycle - 1
        elif cycle > max_forward_cycle:
            continue
        rate = round(record[2], 4)
        yield record[0], cycle, rate