# Arup Guha
# Edited on 7/9/2024
# Showing how to custom sort in Python.

import random

class Thing:
    def __init__(self):
        self.x = random.randint(1, 10)
        self.y = random.randint(1, 100)

    def __str__(self):
        return f"{self.x}, {self.y}"

    # override this for custom sort! Here we sort by x, breaking ties by
    # y in reverse order.
    def __lt__(self, other):
        return self.x < other.x or (self.x == other.x and self.y > other.y)

# Create 10 random things and print.
things = [Thing() for _ in range(10)]
print([str(t) for t in things])
print("-----------------")

# Sort and print again.
things.sort()
print([str(t) for t in things])
