title: Sort list of complex numbers and get sorting indexes
body: <p>I need to sort a <code>list</code> of complex numbers by the imaginary parts. I found the solution on the question “<a href="https://bytes.com/topic/python/answers/852540-sorting-list-complex-numbers" rel="nofollow noreferrer">sorting list of complex numbers</a>”.</p>
  
  <p>Simply using the sorted command with the appropriate key:</p>
  
  <pre><code>list_ordered = sorted(list, key=lambda x: x.imag) 
  </code></pre>
  
  <p>I'd also like to get back the sorting indexes. <a href="https://stackoverflow.com/questions/6422700/how-to-get-indices-of-a-sorted-array-in-python/6423325">Another existing solution</a> doesn't work in the case of complex numbers. Is there an elegant solution to extract the indexes in my case?</p>
  
  <p>Thanks!</p>