I have a dictionary that has company names as keys. The values are a namedtuple of two things. entity having a link to company url and grade having a numerical value. I would like to sort this dictionary based on value and specifically by grade. I am trying to use key function as key=lambda (k,v):v.grade. But I am getting an error pointed at the bracket next to lambda keyword. Code snippet is below. Can anyone please help?
sorted_dict = sorted(list(dict_interested_companies.items()), key=lambda (k,v):v.grade)
For example, Display values of dict.items()
[('Google', named_tuple(entity='http://money.cnn.com/video/technology/2018/02/01/kevin-abosch-i-am-a-coin.cnnmoney/index.html', grade=45)), ('Comcast', named_tuple(entity='http://money.cnn.com/2018/02/02/pf/college/public-service-student-loan-forgiveness/index.html', grade=39))