I have the following dataframe
A B
b 10
b 5
a 25
a 5
c 6
c 2
b 20
a 10
c 4
c 3
b 15
How can I sort it as follows:
A B
b 20
b 15
b 10
b 5
a 25
a 10
a 5
c 6
c 4
c 3
c 2
Column A is sorted based on the sum of corresponding values in column B in descending order(The sums are b-50, a-40, c-15) .