Steven D'Aprano <steve+pyt...@pearwood.info> added the comment:
Since sort is guaranteed to be stable, can't you sort in two runs? py> values = ['bc', 'da', 'ba', 'abx', 'ac', 'ce', 'dc', 'ca', 'aby'] py> values.sort(key=itemgetter(1), reverse=True) py> values.sort(key=itemgetter(0)) py> values ['ac', 'abx', 'aby', 'bc', 'ba', 'ce', 'ca', 'dc', 'da'] Its not as efficient as doing a single sort, but its easier to understand than a complex API to specify each item's sort direction individually, and therefore probably less likely to mess it up and get it wrong. ---------- nosy: +steven.daprano, tim.peters _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue35010> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com