if icount(i) < icount(k) or icount(i) == icount(k) and icount(j) < icount(l):
    return -1
return 1
input = [[0, 0], [1, 2], [1, 4], [2, 2], [2, 3], [3, 3], [3, 4]]
for i, j in input:
    add_item(i)
add_item(j)
input.sort(key=cmp_to_key(cmp_items))
print(input)
Sorting a list pairs by frequency of the pair elements