Given a list of [start, end] intervals, merge every set of overlapping intervals and return the result sorted by start.
Intervals that only touch (like [1, 3] and [3, 5]) count as overlapping. The input may be in any order.
Example
merge([[8, 10], [1, 3], [2, 6], [15, 18]])
# [[1, 6], [8, 10], [15, 18]]