#include <iostream>
#include <iomanip>
#include <deque>
#include <string>
#include <iterator>
#include <algorithm>
using namespace std;
class ID{
private:
string name;
int score;
public:
ID(string name, int score) :name(name), score(score){};
friend bool operator <(const ID &, const ID &);
void display(){
cout.setf(ios::left);
cout << setw(3) << score << name << endl;
}
};
bool operator < (const ID& a, const ID& b){
return a.score < b.score;
}
typedef deque<ID> Deque;
int main(){
Deque d;
Deque::iterator iter;
d.push_back(ID("Smith A", 96));
d.push_back(ID("Amstrong B.", 91));
d.push_back(ID("Watson D", 82));
for (iter = d.begin(); iter != d.end(); iter++){
iter->display();
}
sort(d.begin(), d.end());
cout << endl << "Sorted by Score " << endl;
cout << "==================" << endl;
for (iter = d.begin(); iter != d.end(); iter++){
iter->display();
}
cout << endl << "Reverse output" << endl;
cout << "==================" << endl;
Deque::reverse_iterator r = d.rbegin();
while (r != d.rend()){
(r++)->display();
}
cout << endl;
return 0;
}