This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author steven.daprano
Recipients cykerway, steven.daprano, tim.peters
Date 2018-10-17.10:34:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1539772456.61.0.788709270274.issue35010@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2018-10-17 10:34:16steven.dapranosetrecipients: + steven.daprano, tim.peters, cykerway
2018-10-17 10:34:16steven.dapranosetmessageid: <1539772456.61.0.788709270274.issue35010@psf.upfronthosting.co.za>
2018-10-17 10:34:16steven.dapranolinkissue35010 messages
2018-10-17 10:34:16steven.dapranocreate