Raymond Hettinger <raymond.hettin...@gmail.com> added the comment:

FWIW, the new dataclasses module makes it really easy to create a wrapper:

    from dataclasses import dataclass, field
    from typing import Any

    @dataclass(order=True)
    class KeyedItem:
        key: int
        item: Any=field(compare=False)

    def f(): pass
    def g(): pass
    print(sorted([KeyedItem(10, f), KeyedItem(5, g)]))

I'm thinking of just making an example in the docs and closing this out.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue31145>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to