Raymond Hettinger wrote: > If the discussion is wrapped up, I'm ready to commit the patch: > > www.python.org/sf/823292 > > Summary: > > .. Adds keyword arguments: cmp, key, reverse. > .. Stable for any combination of arguments (including reverse). [ ... ] On the sf tracker item you write: def sort(self, cmp=None, key=None, reverse=None): if cmp is not None and key is not None: cmp = cmpwrapper(cmp) if key is not None: self[:] = [sortwrapper(key(x), x) for x in self] if reverse is not None: self.reverse() self.sort(cmp) if key is not None: self[:] = [x.getvalue() for x in self] if reverse is not None: self.reverse() Is there consensus at all about the necessity of that first reverse call? To me it's not immediately obvious that the reverse option should maintain the _original_ stable order. In my particular application I would actually want reverse to do just that: reverse the result of the sort. Easy enough to work around of course: I could do the reverse myself after the sort. But it does feel odd: sort() now _has_ a reverse feature, but I can't use it... (Also: how does timsort perform when fed a (partially) sorted list compared to a reversed sorted list? If there's a significant difference there, than that first reverse call may actually hurt performance in some cases. Not that I care much about that...) Just
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4