title: Get the indices of an array after sorting?
body: <p>Suppose the user enter an array, for example:</p>
  
  <pre><code>Array = {France, Spain, France, France, Italy, Spain, Spain, Italy}
  </code></pre>
  
  <p>which I did know the length of it</p>
  
  <p>the <code>index</code> array would be:</p>
  
  <pre><code>index = {0, 1, 2, 3, 4, 5, 6, 7}
  </code></pre>
  
  <p>Now, after sorting it using <code>Arrays.sort(Array);</code></p>
  
  <p><code>newArray</code> will be like:</p>
  
  <pre><code>newArray = {France, France, France, Italy, Italy, Spain, Spain, Spain}
  </code></pre>
  
  <p>and the <code>newIndex</code> will be:</p>
  
  <pre><code>newIndex = {0, 2, 3, 4, 7, 1, 5, 6}
  </code></pre>
  
  <p>The problem is: how can I find the <code>newIndex</code> from the input Array?</p>
  
  <p>Thanks in advance</p>