title: Sort an array according to one parameter
body: <pre><code>#include&lt;bits/stdc++.h&gt;
  
  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",&amp;n,&amp;q);
      struct node *a=(struct node *)malloc(n*sizeof(struct node));
      struct node *c=(struct node *)malloc(sizeof(struct node));
      for(i=0;i&lt;n;i++){
          scanf("%lld",&amp;f);
          a[i].d=f;
          a[i].e=i;
      }
  }
  </code></pre>
  
  <p>If I want to sort this array only by the 'd' parameter, then how would I do so using the sort function prescribed in <code>stl</code>?
  I want to sort this array while preserving the index.
  If the array followed by the index on the next line is:</p>
  
  <pre><code>4 2 1 3
  
  0 1 2 3
  </code></pre>
  
  <p>Then I want my output to be:</p>
  
  <pre><code>1 2 3 4
  
  2 1 3 0
  </code></pre>