Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

sorted is always a list, whereas reversed is an iterator (at least in Python 3)


Same 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...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: