Click
Here to go back to the homepage.
Sort of Sorting Solution:
#include <bits/stdc++.h>
using namespace std;
int main() {
// #ifndef TESTING
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
// #endif
for(int i; cin >> i && i;){
vector<string> names;
for (size_t name = 0; name < i; name++)
{
string n;
cin >> n;
names.push_back(n);
}
stable_sort(names.begin(), names.end(), [](const string &a, const string &b){ return a[0] < b[0] ? true : a[0] > b[0] ? false : a[1] < b[1];} );
for_each(names.begin(), names.end(), [](const string &s){ cout << s << endl;});
cout << endl;
}
return 0;
}