Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (19.9k points)

I am trying to sort below dictionary based on "resume_match_score" in descending order.

{'16334': [{'skill_match': {'java': 33,

    'python': 5,

    'swing': 1,

    'apache cassandra': 1},

   'skill_match_score': 0.8},

  {'doc_attachment': '97817_1560102392mahesh-java.docx',

   'document_path': '06_2019',

   'firstname': 'nan',

   'lastname': 'nan'},

  {'job_title_match': {'java developer': 3}, 'job_title_match_score': 0.5},

  {'resume_match_score': 0.71}],

 '4722': [{'skill_match': {'java': 24, 'python': 1, 'hadoop': 31},

   'skill_match_score': 0.6},

  {'doc_attachment': '4285_1560088607Srujan_Hadoop.docx',

   'document_path': '06_2019',

   'firstname': 'nan',

   'lastname': 'nan'},

  {'job_title_match': {'hadoop developer': 3, 'java developer': 2},

   'job_title_match_score': 1.0},

  {'resume_match_score': 0.72}]

I tried as below and this seems to be working but giving only key instead of full dictionary object.

result = sorted(test_d, key=lambda k: test_d[k][3].get("resume_match_score", 0), reverse=True)

and

result = ['4722', '16334']

How to get complete dictionary in sorted order based on key resume_match_score?

Thanks in advance.

1 Answer

0 votes
by (25.1k points)

Use this code:

real_result = [] 

for key in result: 

     real_result.append((key, dict.get(key))

Related questions

Browse Categories

...