#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
struct properties{
int index; // student's index number
string name; // name of student
int points; // points of exam
bool sorter(properties a, properties b){
return a.points < b.points;
}
};
int main()
{
properties students[6];
vector<int> v;
for(int i = 0; i < 6; i++){
cin >> students[i].index >> students[i].name >> students[i].points;
}
for(int i = 0; i < 6; i++){
v.push_back(students[i].points);
}
stable_sort(students.begin(), students.end(), sorter);
return 0;
}
I have the following program and now I have to expand it to print the elements in sorted order from highest points to lowest. I need the smallest and most simple code because time isn't an issue in my case. Any help is appreciated.
UPDATE: I am getting two errors:
error: expected primary-expression before ',' token
error: expected primary-expression before '+' token
On this line:
sort(properties, properties + 5);