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
For this, you should use std::partition
instead of std::sort
vector c;
std::partition(c.begin(),c.end(),isEven)
With sorting, you typically want the sorting to be based on the relative order of any two elements. In this case, you just want to partition your input based on an inherent property of your elements. Both cases can be reduced to the other, but it is always a little easier to take the direct approach.