I need to sort a list
of complex numbers by the imaginary parts. I found the solution on the question “sorting list of complex numbers”.
Simply using the sorted command with the appropriate key:
list_ordered = sorted(list, key=lambda x: x.imag)
I'd also like to get back the sorting indexes. Another existing solution doesn't work in the case of complex numbers. Is there an elegant solution to extract the indexes in my case?
Thanks!