#include <iostream>
#include <algorithm>
using namespace std;
struct Node {
int i;
char ch;
};
//Custom comparator
bool cmp (const Node &a, const Node &b){
return a.i < b.i;
}
void printArr (Node *a, int N) {
for (int i=0; i<N; i++) {
cout<<a[i].i<<" "<<a[i].ch<<endl;
}
}
int main() {
int N = 3;
Node a[N];
a[0].i = 2;
a[0].ch = 'b';
a[1].i = 1;
a[1].ch = 'a';
a[2].i = 3;
a[2].ch = 'c';
cout<<"Array before sorting:"<<endl;
printArr(a, N);
sort(a, a+N, &cmp);
cout<<"Array after sorting:"<<endl;
printArr(a, N);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKc3RydWN0IE5vZGUgewogICAgaW50IGk7CiAgICBjaGFyIGNoOwp9OwoKLy9DdXN0b20gY29tcGFyYXRvciAKYm9vbCBjbXAgKGNvbnN0IE5vZGUgJmEsIGNvbnN0IE5vZGUgJmIpewogICAgcmV0dXJuIGEuaSA8IGIuaTsKfQoKdm9pZCBwcmludEFyciAoTm9kZSAqYSwgaW50IE4pIHsKCQoJZm9yIChpbnQgaT0wOyBpPE47IGkrKykgewoJICBjb3V0PDxhW2ldLmk8PCIgIjw8YVtpXS5jaDw8ZW5kbDsKCX0KCQp9CgppbnQgbWFpbigpIHsKCglpbnQgTiA9IDM7CgkKCU5vZGUgYVtOXTsKCWFbMF0uaSA9IDI7CglhWzBdLmNoID0gJ2InOwoJYVsxXS5pID0gMTsKCWFbMV0uY2ggPSAnYSc7CglhWzJdLmkgPSAzOwoJYVsyXS5jaCA9ICdjJzsKCQoJY291dDw8IkFycmF5IGJlZm9yZSBzb3J0aW5nOiI8PGVuZGw7CglwcmludEFycihhLCBOKTsKCQoJc29ydChhLCBhK04sICZjbXApOwoJCgljb3V0PDwiQXJyYXkgYWZ0ZXIgc29ydGluZzoiPDxlbmRsOwoJcHJpbnRBcnIoYSwgTik7CgoJcmV0dXJuIDA7Cn0=