title: Find the index by current sort order of an array in ruby
body: <p>If there is an array </p>
  
  <pre><code>array A = ["a","b","c","d"] #Index is [0,1,2,3]
  </code></pre>
  
  <p>And it's sorted to.</p>
  
  <pre><code>array A = ["d","c","b","a"]
  </code></pre>
  
  <p>I need an array that returns me the updated index based on the sorted order</p>
  
  <pre><code>[3,2,1,0]
  </code></pre>
  
  <p>I'm trying to find a solution to this ruby</p>
  
  <p><strong>UPDATE to the question</strong></p>
  
  <p>If a is sorted to <br></p>
  
  <pre><code>array A = ["d","b","c","a"] #not a pure reverse
  </code></pre>
  
  <p>Then the returned index array should be</p>
  
  <pre><code>[3,1,2,0]
  </code></pre>