What is the logic behind this?

#include
#include
using namespace std;
bool compare(int a ,int b)
{
return a>=b;

}

int main()
{
int a[10]={1,2,4,5,6,7,8};
int k= 3;
int *lb = lower_bound(a,a+7,k,compare);
int j=lb-a;
cout<<j<<endl<<a[j];
here i get the output as 7 and 0 which means i got the value at 7th index which means 0 but i wanted that the value i should get is 1 and 2 beacuse i changed the compare function.what is the problem in this . please explain?

For implementing binary search you have to sort the array first

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.