1 2 3 4 5 6 7 8
def cmp_frames(a, b): y_diff = int(a[1] - b[1]) x_diff = int(a[2] - b[2]) if y_diff > 0: return y_diff else: return -x_diff