#!/usr/bin/env python # import sys def cmpLast2disgits(x, y): return ((x % 100) - (y % 100)) N = 10 power3 = N*[None] cubes = N*[None] for n in range(0, N): power3[n] = 3**n cubes[n] = n**3 sys.stdout.write("power3=%s\n" % power3) sys.stdout.write("cubes=%s\n" % cubes) sys.stdout.write("Sort by last 2 digits\n") power3.sort(cmpLast2disgits); # By real compare function cubes.sort(lambda x, y: ((x % 100) - (y % 100)) ); # by unnamed function sys.stdout.write("power3=%s\n" % power3) sys.stdout.write("cubes=%s\n" % cubes) sys.exit(0)