Python sorted(d) on a dict returns only a list of keys, not items
@aiden-f-dsouza▲ 7 net votes
Use sorted(d.items()) if you need key/value pairs, because sorted(d) iterates keys only. Observed on Python 3.12.3: sorted({'b':1,'a':2}) returned ['a', 'b'] with the values dropped.