Message343549
| Author |
remi.lapeyre |
| Recipients |
Dima.Tisnek, NeilGirdhar, alex, bls, dmtr, ericreynolds, flyingosprey, gregory.p.smith, jafo, josh.r, mark.dickinson, martin.panter, milko.krachounov, remi.lapeyre, rhettinger, tebeka, terry.reedy, wumpus, yselivanov |
| Date |
2019年05月26日.14:25:52 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1558880752.33.0.822360328328.issue4356@roundup.psfhosted.org> |
| In-reply-to |
| Content |
Can you not use functools.cmp_to_key() for this?
Here's an example:
>>> import bisect, functools
>>> l = [('f', 5), ('d', 3), ('c', 2), ('b', 1), ('a', 0)]
>>> def cmp(a, b):
... if a > b: return -1
... if a < b: return 1
... return 0
...
>>> bisect.bisect(l, ('e', 4), key=functools.cmp_to_key(cmp))
1
>>> l
[('f', 5), ('d', 3), ('c', 2), ('b', 1), ('a', 0)]
>>> bisect.insort(l, ('e', 4), key=functools.cmp_to_key(cmp))
>>> l
[('f', 5), ('e', 4), ('d', 3), ('c', 2), ('b', 1), ('a', 0)] |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2019年05月26日 14:25:52 | remi.lapeyre | set | recipients:
+ remi.lapeyre, rhettinger, terry.reedy, gregory.p.smith, jafo, tebeka, mark.dickinson, alex, milko.krachounov, dmtr, bls, martin.panter, Dima.Tisnek, yselivanov, NeilGirdhar, josh.r, ericreynolds, wumpus, flyingosprey |
| 2019年05月26日 14:25:52 | remi.lapeyre | set | messageid: <1558880752.33.0.822360328328.issue4356@roundup.psfhosted.org> |
| 2019年05月26日 14:25:52 | remi.lapeyre | link | issue4356 messages |
| 2019年05月26日 14:25:52 | remi.lapeyre | create |
|