I could not understand why below piece of code is not sorting first two elements of vector :
int main() {
std::vector<int> v = {2,1,3,1,2};
std::sort(v.begin(),v.begin()+1);
for(auto elem:v)
{
std::cout<<elem<<std::endl;
}
// your code goes here
return 0;
}
Any thoughts ?