Created
February 22, 2019 20:40
-
-
Save toddlipcon/d45d943dc281d008eb14bf7ef7d82c0e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <algorithm> | |
#include <iostream> | |
#include <vector> | |
#include <utility> | |
using namespace std; | |
int main( int argc, char *argv[] ) { | |
vector<pair<int, int>> pairs = { | |
{2, 3}, | |
{2, 4}, | |
{2, 3}, | |
{1, 2}}; | |
std::sort(pairs.begin(), pairs.end(), [](const pair<int, int>& a, const pair<int, int>& b) { | |
return a.second - b.second; | |
}); | |
for (auto& p : pairs) { | |
cout << p.first << ", " << p.second << endl; | |
} | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment