#include <vector>
#include <algorithm>
#include <iostream>
const int COL = 2;
bool compare_vectors(const std::vector<int>& lhs, const std::vector<int>& rhs)
{
return rhs.back() < lhs.back();
}
int main()
{
std::vector<std::vector<int>> Arr = {{1, 5}, {2, 8}, {3, 3}};
std::sort(Arr.begin(), Arr.end(), compare_vectors);
// IDEone still has an outdated compiler, no range loops
// for(auto& row: Arr)
// {
// for(auto& n: row)
// std::cout << n << ' ';
// std::cout << '\n';
// }
for(std::size_t row = 0; row < Arr.size(); ++row)
{
for(std::size_t col = 0; col < Arr[row].size(); ++col)
std::cout << Arr[row][col] << ' ';
std::cout << '\n';
}
}
I2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPGlvc3RyZWFtPgoKY29uc3QgaW50IENPTCA9IDI7Cgpib29sIGNvbXBhcmVfdmVjdG9ycyhjb25zdCBzdGQ6OnZlY3RvcjxpbnQ+JiBsaHMsIGNvbnN0IHN0ZDo6dmVjdG9yPGludD4mIHJocykKewogICAgcmV0dXJuIHJocy5iYWNrKCkgPCBsaHMuYmFjaygpOwp9CgppbnQgbWFpbigpCnsKICAgIHN0ZDo6dmVjdG9yPHN0ZDo6dmVjdG9yPGludD4+IEFyciA9IHt7MSwgNX0sICB7MiwgOH0sIHszLCAzfX07CgogICAgc3RkOjpzb3J0KEFyci5iZWdpbigpLCBBcnIuZW5kKCksIGNvbXBhcmVfdmVjdG9ycyk7CgoKLy8gSURFb25lIHN0aWxsIGhhcyBhbiBvdXRkYXRlZCBjb21waWxlciwgbm8gcmFuZ2UgbG9vcHMKLy8gICAgZm9yKGF1dG8mIHJvdzogQXJyKQovLyAgICB7Ci8vICAgICAgICBmb3IoYXV0byYgbjogcm93KQovLyAgICAgICAgICAgIHN0ZDo6Y291dCA8PCBuIDw8ICcgJzsKLy8gICAgICAgIHN0ZDo6Y291dCA8PCAnXG4nOwovLyAgICB9CiAgICBmb3Ioc3RkOjpzaXplX3Qgcm93ID0gMDsgcm93IDwgQXJyLnNpemUoKTsgKytyb3cpCiAgICB7CiAgICAgICAgZm9yKHN0ZDo6c2l6ZV90IGNvbCA9IDA7IGNvbCA8IEFycltyb3ddLnNpemUoKTsgKytjb2wpCiAgICAgICAgICAgIHN0ZDo6Y291dCA8PCBBcnJbcm93XVtjb2xdIDw8ICcgJzsKICAgICAgICBzdGQ6OmNvdXQgPDwgJ1xuJzsKICAgIH0KfQo=