• Merges two sorted arrays anArray1 and anArray2 according to the comparator aCmpFun.

    Both arrays are supposed to be sorted according to cmpFun.

    This function is used in particular in the arrayMergeSortGen function. It uses a recursive algorithm, but is not pure.

    Parameters

    • anArray1: any[]

      the first array to be merged

    • anArray2: any[]

      the second array to be merged

    • aCmpFun: ((a1: any, a2: any) => number)

      a 2-parameter function returning a number n, telling if the 1st parameter is less-than (n < 0), equal (n == 0) or greater than the 2nd (n > 0)

        • (a1, a2): number
        • Parameters

          • a1: any
          • a2: any

          Returns number

    Returns any[]

    a new array with the union of the elements af anArray1 and anArray2 sorted