#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <iterator>

using namespace std;

int main() {
	int ar[5][2] = { {20, 11}, {10, 20}, {39, 14}, {29, 15}, {22, 23} };
	const auto subArraySize = sizeof(*ar);
	static const auto SIZE = subArraySize / sizeof(int);

	qsort(ar, sizeof(ar) / subArraySize, subArraySize, [](const auto lhs, const auto rhs) {
		const auto first = reinterpret_cast<const int*>(lhs);
		const auto last = next(first, SIZE);
		const auto its = mismatch(first, last, reinterpret_cast<const int*>(rhs));

		if (its.first == last) {
			return 0;
		} else if (*its.first < *its.second) {
			return -1;
		} else {
			return 1;
		}});

	for (const auto& i : ar) {
		for (const auto& j : i) cout << j << '\t';
		cout << endl;
	}
}