If i already have a method that gets and returns the values, then i'll just have to add the struct in my class file, and do the following below in main to sort?
//Descending using function object:
std::sort(var.begin(), var.end(), foo_comparer());
for(auto s: var)
std::cout << s.getFloatValue() << ' ';
std::cout << '\n';
If i already have a method that gets and returns the values, then i'll just have to add the struct in my class file, and do the following below in main to sort?
Basicly yes. I do not have access to your class, so I had to create a quick mock-up of class with getFloatValue member.
You can do sorting in four ways:
1) Using lambda (Shown in previous posts)
2) Using function object (Shown in previous post)
3) Using function: