```
class Solution(object):
def insert(self, intervals, newInterval):
i = 0
while i <= len(intervals):
if i == len(intervals) or intervals[i].start > newInterval.end:
intervals.insert(i,newInterval)
break
if intervals[i].end < newInterval.start:
i += 1
continue
newInterval.start, newInterval.end = min(newInterval.start, intervals[i].start), max(newInterval.end, intervals[i].end)
intervals.pop(i)
return intervals
```