I have a vector containing data such as: 15,27,40,50,15,40
I want to sort it and remove the same value, so the output after the sort should be: 15,27,40,50
I've tried several ways such:
std::sort(vectProjHori.begin(),vectProjHori.end());
for (std::vector<int>::iterator it=vectProjHori.begin(); it!=vectProjHori.end(); ++it)
{
if(it+1 != it)
{
std::cout << ' ' << *it;
}
}
But, it can't remove the same value in the vector. I really hope someone would like to give an efficient way how to do it.
Any help would be highly appreciated. Thank you