I would like to know is it possible to sort number by even or odd using the std::sort function.
I have the following codes but i am not sure how to implement in the
If you look at a reference for std::sort you will see that the function it uses to compare should take two arguments that it should compare. So your code will not work at all.
I recommend you instead iterate over the vector, sorting out even values into one temporary vector, and the odd values into another temporary vector. Then you clear the actual vector, and append the two temporary vectors in the order you like.