I have a Pair class (it has a key and a value) and I'm trying to make a program which creates a bunch of Pair objects, adds them to a list, and performs **stable quicksort** on them. However, I can't seem to figure how to make the objects comparable so that the program automatically compares the keys of two objects when they have the same value. It's so easy to do this in Java but I just don't get how I'm supposed to do the equivalent in Python.

Thank you in advance!

```
class Pair(Generic[K,V]):
    def __init__(self, key: K, val: V):
        self.key = key
        self.value = val

```