import { binarySearch } from "https://deno.land/x/fun@v2.0.0/array.ts";
Given an Sortable over A, create a binary search function for a sorted ReadonlyArray that returns the array index that the new value should be inserted at in order to maintain a sorted array.
Examples
Example 1
Example 1
import * as A from "./array.ts";
import { SortableNumber } from "./number.ts";
import { pipe } from "./fn.ts";
const search = A.binarySearch(SortableNumber);
const arr = A.range(100, 1); // [1, 2, ..., 100]
const index1 = search(30.5, arr); // Index 29
const index2 = search(10000, arr); // Index 100