Sort by more than one field.
sorted(
key=
def rank(trades): # TODO: sort twice, least significant key first (stable sort) pass