title: c++ I need to read data from a file into a multi-dimensional array then sort the array with one data type. How?
body: <p>I need to sort the net pays of employees as part of a payroll program. Employees are identified by an id number followed by their net pay. Like this:</p>
  
  <pre><code>11111 456.78
  22222 891.01
  33333 112.13
  </code></pre>
  
  <p>I need to sort the data so that it looks like this</p>
  
  <pre><code>22222 891.01
  11111 456.78
  33333 112.13
  </code></pre>
  
  <p>So basically I  need to sort them by their pay but I need the id number to match the sorted pay.</p>
  
  <p>code i have so far:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;iomanip&gt;
  #include &lt;algorithm&gt;
  
  using namespace std;
  
  /* Read data from file into array*/
  int readData(long int[], double[], int);
  
  /*print data from array unsorted*/
  void printUnsorted(long int[], double, int);
  
  /* sort items from array*/
  void sort(long int[], double[], int);
  
  /*Display sorted data to console*/
  void printSorted(long int[], double, int);
  
  void main() {
  
      const int MAXSIZE = 100;
  
      int n;
      long int id[MAXSIZE];
      double netpay[MAXSIZE];
  
      n = readData(id, netpay, MAXSIZE);
      printUnsorted(id, netpay);
      sort(id, netpay);
      printSorted(id, netpay);
  }
  
  int readData(long int id[], double netpay[], int n) {
      ifstream input;
      input.open("netpay.txt");
      n = 0;
  
      while (input &gt;&gt; id[n] &gt;&gt; netpay[n]) n++;
  
      input.close();
      return n;
  }
  
  void printUnsorted(long int id[], double netpay[], int n) {
      cout &lt;&lt; "Unsorted Data" &lt;&lt; endl;
      for (int i = 0; i &lt; n; i++) {
          cout &lt;&lt; id[i] &lt;&lt; "\t" &lt;&lt; netpay[i] &lt;&lt; "\t" &lt;&lt; endl;
      }
  
  
  void sort(long int id[], double netpay[], int n) {
      for (int i = 0; i &lt; n; i++) {
          sort(netpay.begin(), netpay.end()); 
      }   
  }
  
  void printSorted(long int id[], double netpay[], int n) {
      cout &lt;&lt; "Sorted Data" &lt;&lt; endl;
      for (int i = 0; i &lt; n; i++) {
          cout &lt;&lt; id[i] &lt;&lt; "\t" &lt;&lt; netpay[i] &lt;&lt; "\t" &lt;&lt; endl;
      }   
  }
  </code></pre>
  
  <p>Very messy I know, can anyone give me a step in the right direction? After this I have to do the same thing with pointers.</p>