I\'m working on a project for school and need to sort some data. I\'ve been given a vector of objects and I have to sort the objects (either in place or using an index) base
Use std::sort and a functor. e.g:
std::sort
struct SortByX { bool operator() const (MyClass const & L, MyClass const & R) { return L.x < R.x; } }; std::sort(vec.begin(), vec.end(), SortByX());
The functor's operator() should return true if L is less than R for the sort order you desire.