HTML & JS
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

void array(vector<int> v, int n, int k)
{

	int sum = 0;
	int index;
	string str = " ";
	vector<pair<int, int> > arr;
	for (int i = 0; i < n - 1; i++) {
		index = i;
		str = to_string(v[i]);
		i++;
		for (int j = 0; j < k - 1; j++) {
			string temp = to_string(v[i]); // Conversion of array elements(integers) to string for easy concatination
			str += temp;
			if (j != k - 2)
				i++;
		}
		stringstream check(str);
		int s = 0;
		check >> s; // Conversion of concatinated string to integer
		arr.push_back(make_pair(s, index));
		index++;
	}
	int u = 0;
	sort(arr.begin(), arr.end()); // Sorting of array
	vector<int> v2;
	for (int i = 0; i < (n / k); i++) {
		u = 0;
		int j = arr[i].second;
		while (u < k) {
			int a = v[j];
			v2.push_back(a);
			u++;
			j++;
		}
	}
	for (int i = 0; i < n; i++) {
		cout << v2[i] << " ";
	}
}

int main()
{
	// Your C++ Code
	int n;
	cin >> n;
	vector<int> v;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		v.push_back(a);
	}
	int k;
	cin >> k;
	array(v, n, k);
	return 0;
	return 0;
	// This code is contributed by Siddhant Thapliyal
}

Generated URL:

Runtime Errors:

Segmentation Fault (SIGSEGV)

Output:

No Output
Report Bug