vector<int> v = {1, 3, 5, 2};
// 오름차순
sort(v.begin(), v.end());
// 내림차순
sort(v.end(), v.begin());
// 1차원
int arr[3] = {9, 3, 2};
sort(arr, arr+3);
// 2차원
int arr[2][3] = { {9, 3, 2}, {2, 4, 1} };
sort(arr[0], arr[0]+3);
stable하게 정렬하는 STL 함수
template< class RandomIt >
void stable_sort( RandomIt first, RandomIt last );
template< class RandomIt, class Compare >
void stable_sort( RandomIt first, RandomIt last, Compare comp );
#include <bits/stdc++.h>
using namespace std;
bool comp(pair<int, string> a, pair<int, string> b){
return a.first < b.first;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
pair<int, string> p;
vector<pair<int, string>> member;
cin >> n;
for(int i=0; i<n; i++){
cin >> p.first >> p.second;
member.push_back(p);
}
stable_sort(member.begin(), member.end(), comp);
for(int i=0; i<n; i++){
cout << member[i].first << " " << member[i].second << "\n";
}
return 0;
}