More details I have a list of tuples l = [((cpu_util,mem_util),(disk_util)), ((cpu_util,mem_util),(disk_util))] ie, l = [((30,50),(70)), ((50,20),(20))]
l.sort(key=lambda x:(-x[0][0], x[1][0])) # sorting cpu_util asc and disk_util desc suppose i changed order that is l = [((mem_util,cpu_util), (disk_util)), ((mem_util,cpu_util),(disk_util))] So i have to change the sort code to l.sort(key=lambda x:(-x[0][1], x[1][0])) # sorting cpu_util asc and disk_util desc I want to use same (common) sort code, that must work even if i changed tuple order. -- http://mail.python.org/mailman/listinfo/python-list