Merges two sorted arrays, returning result.

const a = [ 4, 7, 10 ]
const b = [ 1, 2, 9, 11 ]
const c = merge(a, b);
// [ 1, 2, 4, 7, 9, 10, 11 ]

Undefined behaviour if either input array is not sorted.

By default uses Javascript comparision semantics. Passing in comparer is needed when working with an array of objects.

  • Type Parameters

    • T

    Parameters

    • a: T[]

      Sorted array

    • b: T[]

      Sorted array

    • comparer: Comparer<T> = defaultComparer

      Comparator

    Returns T[]