#include <algorithm>
#include <vector>
#include <iostream>
#include <string>
using namespace std;
typedef struct information
{
int index;
string name;
}Test;
bool comp(Test x, Test y)
{
return x.index > y.index;
}
int main(int argc, char *argv[])
{
cout << "==============================================================" << endl;
cout << "hello welcome to you" << endl;
vector<Test> one;
Test temp;
temp.index = 0;
temp.name = "c";
one.push_back(temp);
temp.index = 5;
temp.name = "x";
one.push_back(temp);
temp.index = 3;
temp.name = "y";
one.push_back(temp);
vector<Test>::iterator pos;
for(pos = one.begin(); pos != one.end(); pos++)
{
cout << pos->index << " " << pos->name << endl;
}
cout << "-----------------sort end----------------------" << endl;
stable_sort(one.begin(), one.end(), comp);
for(pos = one.begin(); pos != one.end(); pos++)
{
cout << pos->index << " " << pos->name << endl;
}
cout << "==============================================================" << endl;
return 0;
}
//g++ mystl.cc -o mystl