This is basically the same question at:
How do I sort a dictionary by value?
However instead my dictionary value is a tuple with four floats. How do I key off of an element in the nested tuple?
sorted_dict = {k: dict_cleanwhite[k] for k in
sorted(dict_cleanwhite.items(), key=operator.itemgetter(1), reverse=True)}
Output is:
KeyError: ('43 \n', (776.52, 466.3, 785.37504, 477.34))
How do I select the nested tuple element 776?
Started writing a function to return the tuple element:
def get_item(op_obj):
for v in op_obj:
return v
The problem is that the type operator.itemgetter
returned is not identified, guessing to read documentation.