I feel really dumb not to be able to solve something like this, but I'm point blank. I need to come up with a short and elegant way to do this, and for some reason I just can't!
The concept is very simple
I have a list with [4,3,5,2,1] and I have five individuals A, B, C, D, E
A=4 B=3 C=5 D=2 E=1
Now, I need to arrange them in ascending order based on their numbers so they become
['E', 'D', 'B', 'A', 'C']
I seriously don't get why I can't figure this one out D:
order = [4, 3, 5, 2, 1]
people = "ABCDE"
result = [x[1] for x in sorted(zip(order, people))]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With