My question is related to the answer of this one:
Sort a Python dictionary by value
And for those wishing to sort on keys instead of values:
import operator x = {1: 2, 3: 4, 4: 3, 2: 1, 0: 0} sorted_x = sorted(x.items(), key=operator.itemgetter(0))
How do I sort on keys like above when my keys are tuples? For example, A: {(-2929109664628200379, 10): table, (-3884855813103006483, 15): chair}
, sorting using the second number from the key.
Edit
Made it by creating a function getKey
to return the value I wanted, now I realize it was a trivial question, thank you @jonrsharpe