How to Build Comparable Classes in Python
Basic tutorial on how to make class instances comparable and sortable
Published in
4 min readApr 1, 2022
Pretty often you’d want to make instances of a user-defined class comparable.
Suppose you need to test that your function returns the correct value. If that value happens to be an object of some class, you can run into a surprise: