Merge Intervals

Note: cmp() must be declared as STATIC