#include <vector>
using std::vector;
#include <algorithm>
using std::sort;
#include <iostream>
using std::cout;
class CartesianPoint
{
private:
int x;
int y;
public:
int getX() const { return x; }
int getY() const { return y; }
CartesianPoint(int x, int y) : x(x), y(y) { }
bool operator< (const CartesianPoint& that) const { return x < that.x; }
};
int main()
{
vector<CartesianPoint> myvector { {10, 13}, {32, 1}, {5, 29}, {12, 6}, {21, 100} };
auto cmpFunc = [](const auto& p1, const auto& p2) { return p1 < p2; };
sort(myvector.begin(), myvector.end(), cmpFunc);
cout << "myvector contains:";
for (const auto& point : myvector)
cout << ' ' << '(' << point.getX() << ',' << point.getY() << ')';
cout << '\n';
}
I2luY2x1ZGUgPHZlY3Rvcj4KdXNpbmcgc3RkOjp2ZWN0b3I7CiAgICAgCiNpbmNsdWRlIDxhbGdvcml0aG0+CnVzaW5nIHN0ZDo6c29ydDsKICAgICAKI2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBzdGQ6OmNvdXQ7CiAgICAgCmNsYXNzIENhcnRlc2lhblBvaW50CnsKICAgcHJpdmF0ZToKICAgICAgaW50IHg7CiAgICAgIGludCB5OwogICAgCiAgIHB1YmxpYzoKICAgICAgaW50IGdldFgoKSBjb25zdCB7IHJldHVybiB4OyB9CiAgICAgIGludCBnZXRZKCkgY29uc3QgeyByZXR1cm4geTsgfQogICAgICBDYXJ0ZXNpYW5Qb2ludChpbnQgeCwgaW50IHkpIDogeCh4KSwgeSh5KSB7IH0KICAgICAgYm9vbCBvcGVyYXRvcjwgKGNvbnN0IENhcnRlc2lhblBvaW50JiB0aGF0KSBjb25zdCB7IHJldHVybiB4IDwgdGhhdC54OyB9Cgp9OwogICAgIAppbnQgbWFpbigpIAp7CiAgIHZlY3RvcjxDYXJ0ZXNpYW5Qb2ludD4gbXl2ZWN0b3IgeyB7MTAsIDEzfSwgezMyLCAxfSwgezUsIDI5fSwgezEyLCA2fSwgezIxLCAxMDB9IH07CgogICBhdXRvIGNtcEZ1bmMgPSBbXShjb25zdCBhdX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