Tell me about a time you worked through short software coding exercises and what you focused on to produce correct, maintainable code.
For the hands-on exercise, implement a function that merges overlapping intervals. Return the merged intervals sorted by start time, handling unsorted input, nested intervals, and intervals that touch.
Input: a list of [start, end] pairs. Output: a merged list of pairs.
Examples: [ [1,3], [2,6] ] returns [[1,6]]; [ [1,2], [3,4] ] returns [[1,2],[3,4]].
Constraints: 0 <= len(intervals) <= 5000, and start <= end.
def merge_intervals(intervals):