Review a given piece of code, then fix the bugs in another given piece of code.
Asked in the LLD round stage. Repair the implementation of merge_intervals, which receives a list of inclusive integer intervals. Return a new list containing merged intervals sorted by start value. Intervals overlap or touch when next_start <= current_end.
merge_intervals(intervals) accepts list[list[int]] and returns list[list[int]]. Do not mutate the input.
def merge_intervals(intervals):