Message327888
| 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:16 | steven.daprano | set | recipients: + steven.daprano, tim.peters, cykerway |
| 2018-10-17 10:34:16 | steven.daprano | set | messageid: <1539772456.61.0.788709270274.issue35010@psf.upfronthosting.co.za> |
| 2018-10-17 10:34:16 | steven.daprano | link | issue35010 messages |
| 2018-10-17 10:34:16 | steven.daprano | create | |