#include<bits/stdc++.h>
using namespace std;
struct node{
long long int d;
long long int e;
};
int main() {
long long int n,q,i,f;
scanf("%lld%lld",&n,&q);
struct node *a=(struct node *)malloc(n*sizeof(struct node));
struct node *c=(struct node *)malloc(sizeof(struct node));
for(i=0;i<n;i++){
scanf("%lld",&f);
a[i].d=f;
a[i].e=i;
}
}
If I want to sort this array only by the 'd' parameter, then how would I do so using the sort function prescribed in stl
?
I want to sort this array while preserving the index.
If the array followed by the index on the next line is:
4 2 1 3
0 1 2 3
Then I want my output to be:
1 2 3 4
2 1 3 0