in reply to Re^2: getting elements from an array based on a value not in the array
in thread getting elements from an array based on a value not in the array

yes, exactly. I would have implemented the cache as an hash with key $target and value the offset of splice.

but you are right. binary search is the best solution if we understood the OP right.

  • Comment on Re^3: getting elements from an array based on a value not in the array