#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) { }
};
static bool myfunction(const CartesianPoint& a, const CartesianPoint& b)
{
return a.getX() < b.getX();
}
int main()
{
vector<CartesianPoint> myvector { {10, 13}, {32, 1}, {5, 29}, {12, 6}, {21, 100} };
sort(myvector.begin(), myvector.end(), myfunction);
cout << "myvector contains:";
for (auto& point : myvector)
cout << ' ' << '(' << point.getX() << ',' << point.getY() << ')';
cout << '\n';
}
I2luY2x1ZGUgPHZlY3Rvcj4KdXNpbmcgc3RkOjp2ZWN0b3I7CgojaW5jbHVkZSA8YWxnb3JpdGhtPgp1c2luZyBzdGQ6OnNvcnQ7CgojaW5jbHVkZSA8aW9zdHJlYW0+CnVzaW5nIHN0ZDo6Y291dDsKCmNsYXNzIENhcnRlc2lhblBvaW50CnsKICAgcHJpdmF0ZToKICAgICAgaW50IHg7CiAgICAgIGludCB5OwoKICAgcHVibGljOgogICAgICBpbnQgZ2V0WCgpIGNvbnN0IHsgcmV0dXJuIHg7IH0KICAgICAgaW50IGdldFkoKSBjb25zdCB7IHJldHVybiB5OyB9CiAgICAgIENhcnRlc2lhblBvaW50KGludCB4LCBpbnQgeSkgOiB4KHgpLCB5KHkpIHsgfQp9OwoKc3RhdGljIGJvb2wgbXlmdW5jdGlvbihjb25zdCBDYXJ0ZXNpYW5Qb2ludCYgYSwgY29uc3QgQ2FydGVzaWFuUG9pbnQmIGIpCnsKICAgcmV0dXJuIGEuZ2V0WCgpIDwgYi5nZXRYKCk7Cn0KCmludCBtYWluKCkgCnsKICAgdmVjdG9yPENhcnRlc2lhblBvaW50PiBteXZlY3RvciB7IHsxMCwgMTN9LCB7MzIsIDF9LCB7NSwgMjl9LCB7MTIsIDZ9LCB7MjEsIDEwMH0gfTsKCiAgIHNvcnQobXl2ZWN0b3IuYmVnaW4oKSwgbXl2ZWN0b3IuZW5kKCksIG15ZnVuY3Rpb24pOyAKCiAgIGNvdXQgPDwgIm15dmVjdG9yIGNvbnRhaW5zOiI7CiAgICAKICAgZm9yIChhdXRvJiBwb2ludCA6IG15dmVjdG9yKQogICAgICAgY291dCA8PCAnICcgPDwgJygnIDw8IHBvaW50LmdldFgoKSA8PCAnLCcgPDwgcG9pbnQuZ2V0WSgpIDw8ICcpJzsKICAgICAgICAgICAKICAgY291dCA8PCAnXG4nOwp9Cg==