I writing a program in C++, I gave a vector of 10 elements(always) and each elements have a value called position, which is an int. I want this vector to be always sorted, so as soon as I update it I sort it with std::sort for now. The thing is most of the time, like 99 percent of the time the vector is already totally sorted.
Should I use std::sort anyway ? or Is there a better way to do ?
ps: The update is: getting a a point from a point cloud, calculate in which element of the vector it belong to regarding some external factor and increasing the counter of the vector element designated. Depending of this counter I will add a new element to the vector and delete one of the old ones.