class foo:

    def __init__(self, a1, a2):
        self.attrb1 = a1
self.attrb2 = a2

def defaultorder(self):
    return self.attrb1, self.attrb2

def __lt__(self, other):
    return self.defaultorder() < other.defaultorder()
How to perform double sort inside an array?