I have a collection (list) of objects. I want to be able to sort the objects without having to provide a callback (lambda function) to sorted() but instead, by implementing functions that could be used to ascertain strict (in)equality between objects of the same type – ala C++.
The __eq__() function implemented on a class allows equality checks. I can’t seem to find any similar functions to implement < and >
How may I implement this in Python?
Via
__lt__()and__gt__().