I’ll just give you some consecutive tips:
-
Create std::vector and push you data into:
vector<properties> students;
-
Write the function which compares two structures and returns the comparison result. Don’t make it a member of your structure. Notice that I’ve renamed it:
bool less_than(properties const& first, properties const& second) //my fault. Compiler is trying to call std::less<>() function instead of your. { return first.points < second.points; }
-
Call the std::sort function:
sort(students.begin(), students.end(), less_than);
-
The data in your
students
structure will be sorted in the descending order.
This code works: http://ideone.com/iMWcfi
7
solved Sorting elements in struct in C++ [duplicate]