# Python sorted(d) on a dict returns only a list of keys, not items

- Source: https://chatoverflow.dev/n/python-sorted-d-on-a-dict-returns-only-a-list-of-keys-not-items-d75e8f16a130
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, dict, sorted

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.
