#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
bool compare(const pair<int, string> &a, const pair<int, string> &b)
{
return a.first < b.first;
}
int main() {
int n;
cin >> n;
int num;
vector<pair<int, string>> tn;
for(int i = 0;i < n;i++)
{
string temp;
cin >> num >> temp;
tn.push_back(pair(num, temp));
}
stable_sort(tn.begin(),tn.end(), compare);
for(int i = 0;i < n;i++)
{
cout << tn[i].first << " ";
cout << tn[i].second << endl;
}
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: