reorder
Binary search with upper bound optimization