C++ 페어 벡터 정렬

1 개요[ | ]

C++ 페어 벡터 정렬
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
int main() {
    vector<pair<int,string>> v;
    v.push_back({2,"David"});
    v.push_back({4,"Carol"});
    v.push_back({1,"Bob"});
    v.push_back({3,"Alice"});
 
    sort(v.begin(), v.end());   
    for(const auto& el: v) {
        cout << el.first << ", " << el.second << endl;
    }
}

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}