title: Sorting algortithm with index in java
body: <p>I have a set of values for srting algorithm. I have successfully sorted them out. But I also want to have the index for each element after sorting. For example like :</p>
  
  <pre><code>Array = [95, 53, 24, 10]
  Output after sorting should be like :
  10 at index 3, 24 at index 2, 53 at index 1 and 95 at index 0
  </code></pre>
  
  <p>I have used the following logic for sorting. But unable to get the indexes</p>
  
  <pre><code>for (int p = 0; p &lt; ((list.size()) - 1); p++) {
      int min = p;                 
      count++;
  
      for(int q=p+1; q&lt;list.size();q++) {
          if(doubleArray[q] &lt; doubleArray[min]) {
              min = q;
          }
      }
  
      double smallNumber = doubleArray[p];
      doubleArray[p] = doubleArray[min];
      doubleArray[min] = smallNumber;                  
  }
  </code></pre>