BinarySearch.vl (28.4 KB)
Looks like BinarySearch gives you two indices and values for which it is guaranteed that
Lower Value <= Search Key <= Upper Value
Your example shows that can be several solutions to the query:
3 <= 3 <= 4
3 <= 4 <= 4
The node outputs one of the solutions. And you could argue it should always be the first or always be the second if there are many, or it should search for
Lower Value < Search Key <= Upper Value
or
Lower Value <= Search Key < Upper Value
(3 <= 3 < 4
)
It might break patches to change this behavior. Since you found a solution I’d keep it as is for now, as it’s not a bug, just an unexpected solution for your specific case.