3 ms·
sorted is always a list, whereas reversed is an iterator (at least in Python 3)
by aldanor 11y ago
sorted is always a list, whereas reversed is an iterator (at least in Python 3)
- masklinn 11y agoSame in Python 2. A collection can even override "reversed" to provide their own reversed collection/iterator[0], not so for `sorted`. [0] https://docs.python.org/3/reference/datamodel.html?highlight=data%20model#object.__reversed__ https://docs.python.org/3/reference/datamodel.html?highlight...