Comparator not working as intended

I made a custom comparator for the lower_bound function, but it is working as usual.

I wanted the function to return the greatest value less than the key. So I made the following comparator

bool comparator(int a, int b)
{
return a>b };

But still the function shows the least value greater than or equal to the key. Please help.

Hello @Doctor_Insult,

Please share your entire code.
STEPS:

  1. Paste your code at https://ide.codingblocks.com/
  2. Save it there.
  3. share the URL generated.

BTW, what you want to achieve by creating the comparator function i.e. the greatest value less than the key is the default operation of lower_bound function.

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.