Sort a list of strings by last N characters in Python 2.3

The Schwartzian transform is usually more efficient than using the cmp argument (This is what newer versions of Python do when using the key argument)

lots_list=['anything']

def returnlastchar(s):     
    return s[10:] 

decorated = [(returnlastchar(s), s) for s in lots_list]
decorated.sort()
lots_list = [x[1] for x in decorated]

I don't have python 2.3 on hand, however, according to this post Sorting a list of lists by item frequency in Python 2.3 http://docs.python.org/release/2.3/lib/typesseq-mutable.html this method should also works for you.

def mycmp(a, b):
    return cmp(a[10:], b[10:])

lots_list.sort(mycmp)