I have a sorted list with no duplicates:

```
L = {1, 2, 5, 7, 8}

```

Given an integer `n`, I want to find the index of `n` if it is to be inserted into `L`.

I have been using

`Length[Select[L, # <= n &]]`

But that is incredibly unoptimal as I should be able to do this in $\log n$ by bisecting the set. How should I approach this?