Yes, this is part of how one of the commonly-taught sorting algorithms builds a final result, by merging together partial results after a divide-and-conquer step. Any guess which algorithm?

alternatively, how would you build an algorithm to solve it in O(n) time?