python 3 https://docs.python.org/3.5/howto/sorting.html#the-old-way-using-the-cmp-parameter
from functools import cmp_to_key
def custom_compare(x, y):
# custom comparsion of x[0], x[1] with y[0], y[1]
return 0
sorted(entries, key=lambda e: (cmp_to_key(custom_compare)(e[0]), e[1]))