Paul Moore added the comment: I think the documentation is fine:
""" The key corresponding to each item in the list is calculated once and then used for the entire sorting process. """ This corresponds with the standard "decorate-sort-undecorate" approach to handling key functions in sorts. It's a common computer science technique, possibly not as familiar to a mathematician, but regardless, the docs clearly state that the key is calculated for each item. Your existing code, with a check for Omega having length 1 and omitting the sort in that case, looks entirely reasonable to me. Maybe you could add a comment "Avoid a costly calculation of the key when length is 1, as we know we don't need to sort then" and leave it at that. ---------- nosy: +paul.moore _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue24075> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com