A simple binary search to be used on sorted arrays

  • Type Parameters

    • T

    Parameters

    • searchArr: T[]

      Sorted Array to be searched

    • el: T

      Element to be compared to array values

    • compare_fn: ((arg0: T, arg1: T) => number)

      Comparison function to be apply el to every element in ar. Should return an positive/ negative integer or 0 if matching.

        • (arg0, arg1): number
        • Parameters

          • arg0: T
          • arg1: T

          Returns number

    Returns number

    Index where search is found or negative index indicating where it would be inserted