#include #include #include using namespace std; struct myStructT{ int pos1; char pos2; }; bool operator <(const myStructT & a, const myStructT & b) { return a.pos1 < b.pos1; }; void makeOne(myStructT & a) { a.pos1= rand() % 100; a.pos2 = 'a' + rand() %26; return; } bool comp(const myStructT & a, const myStructT & b) { return a.pos2 < b.pos2; } void PrintList(vector myList) { int i; for(i=0;i myList; myStructT tmp; srand(time(NULL)); for(i=0;i<15;i++) { makeOne(tmp); myList.push_back(tmp); } cout << "Unsorted List " << endl; PrintList(myList); sort(myList.begin() ,myList.end()); cout << endl; cout << endl; cout << "after First Sort" << endl; cout << endl; PrintList(myList); cout << endl; sort(myList.begin() ,myList.end(),comp); cout << endl; cout << "after Second Sort" << endl; cout << endl; PrintList(myList); cout << endl; }