#include <cstdlib>
#include <iostream>

const int COL = 2;

int compare_rows(const void* lhs, const void* rhs)
{
    auto l = static_cast<const int(*)[COL]>(lhs);
    auto r = static_cast<const int(*)[COL]>(rhs);
    return (*r)[COL-1] - (*l)[COL-1];
}

int main()
{
    int Arr[3][COL] = {{1, 5}, {2, 8}, {3, 3}};

    std::qsort(Arr, 3, sizeof Arr[0], compare_rows);

// IDEone still has an outdated compiler, no range loops
//    for(auto& row: Arr)
//    {
//        for(auto& n: row)
//            std::cout << n << ' ';
//        std::cout << '\n';
//    }
    for(int row = 0; row < 3; ++row)
    {
        for(int col = 0; col < COL; ++col)
            std::cout << Arr[row][col] << ' ';
        std::cout << '\n';
    }
}
