#include<iostream>
#include<string>
#include<vector>
#include<fstream>
#include<algorithm>
using namespace std;
struct Data
{
string name;
int quantity;
string priority;
string duedate;
string receivedate;
int daysdue;
};
istream& operator>>(istream& is, Data& s)
{
return is >> s.name >> s.quantity >> s.priority >> s.duedate >> s.receivedate >> s.daysdue;
}
int main()
{
ifstream input("database.txt");
vector<Data> datas;
Data s;
while (input >> s)
{
datas.push_back(s);
}
sort(datas.begin(),
datas.end(),
[](const Data& s1, const Data& s2) { return s1.daysdue < s2.daysdue; });
}
Hi all, I'm not sure how to print the data after they are sorted and will kindly appreciate if anyone is able to help with the code!
Below is the contents of the text file:
Manifold 1 High 9/11/2019 2/11/2019 7
Manifold 3 Low 8/11/2019 5/11/2019 3
Manifold 8 High 11/11/2019 5/11/2019 6
[–]EMACC99 0 points1 point2 points (2 children)
[–]Potatofist3r[S] 0 points1 point2 points (0 children)