Skip to content
Advertisement

Sorting the values of a dictionary based on values of other dictionary

I have a dictionary that looks like this..

JavaScript

and I have another dictionary with some score like this..

JavaScript

I want to sort the values of “results” dictionary based on values of “score” dictionary.

For example,

For the key ‘agunii2035’, the score dictionary has values [ 4,4,1,3]. So, I want to sort the values of “results” dictionary for the same key as ['agunii3007', 'agunii2006', 'agunii3000','agunii2003'] instead of ['agunii3007', 'agunii2006', 'agunii2003', 'agunii3000'] .

Advertisement

Answer

JavaScript

output

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement