cppreference.com > C++ Algorithms > merge merge Syntax:
      #include <algorithm>
      iterator merge( iterator start1, iterator end1, iterator start2, iterator end2, iterator result );
      iterator merge( iterator start1, iterator end1, iterator start2, iterator end2, iterator result, StrictWeakOrdering cmp );
The merge() function combines two sorted ranges [start1,end1) and [start2,end2) into a single sorted range, stored starting at result. The return value of this function is an iterator to the end of the merged range. If the strict weak ordering function object cmp is given, then it is used in place of the < operator to perform comparisons between elements. merge() runs in linear time. Related topics: inplace_merge set_union sort