def merge_intervals(intervals):
if intervals is None:<EOL><INDENT>return None<EOL><DEDENT>intervals.sort(key=lambda i: i[<NUM_LIT:0>])<EOL>out = [intervals.pop(<NUM_LIT:0>)]<EOL>for i in intervals:<EOL><INDENT>if out[-<NUM_LIT:1>][-<NUM_LIT:1>] >= i[<NUM_LIT:0>]:<EOL><INDENT>out[-<NUM_LIT:1>][-<NUM_LIT:1>] = max(out[-<NUM_LIT:1>][-<NUM_LIT:1>], i[-<NUM_LIT:1>])<EOL><DEDENT>else:<EOL><INDENT>out.append(i)<EOL><DEDENT><DEDENT>return out<EOL>
Merge intervals in the form of a list.