you could only reset that to 0 if the last found key if the current key < last key else keep it at the index of the last key.
this could improve performance in the common situation of a sorted needle.

```
min_idx = key_val > last_key ? last_idx : 0
```