#include <cstddef>
#include <algorithm>
#include <iterator>
#include <iostream>

template<typename T, ::std::size_t N>
static ::std::ostream& print_array(::std::ostream& out, T(&arr)[N]) {
	out << "[" << arr[0];
	for(::std::size_t i = 1; i < N; ++i) {
		out << ", " << arr[i];
	}
	out << "]";
	return out;
}

int main() {
	int array[] = {1, 3, 2, 4};
	auto begin = ::std::begin(array);
	auto end = ::std::end(array);
	
	::std::sort(begin, end);
	print_array(::std::cout, array) << "\n";
	
	::std::sort(begin, end, [](int lhs, int rhs) { return lhs > rhs; });
	print_array(::std::cout, array) << "\n";
	
	::std::sort(begin, end, [](int lhs, int rhs) {
		if(lhs%2 != rhs%2) return lhs%2 < rhs%2;
		else return lhs > rhs;
	});
	print_array(::std::cout, array) << "\n";
}