[Tutor] Sort and compare

Conrad Koziol arkamir at softhome.net
Wed Oct 22 19:26:12 EDT 2003


def compare(a,b):
         if a[1]>b[1]: return 0
         else: return -1

x = [('hello', 2), ('goodbye', 3), ('python', 1)]

x.sort(compare(x))

can you explain what happens to me step by step. That'a were im lost.

Does x sort [-1, 0, 1, -1]????





More information about the Tutor mailing list