In newer Python, I am able to use the sorted function and easily sort out a list of strings according to their last few chars as such:
lots_list = ['anything']
print sorted(lots_list, key=returnlastchar)
def returnlastchar(s):
return s[10:]
How can I implement the above to lots_list.sort() in older Python (2.3)?
” Error: When I tried using sorted(), the global name sorted is not defined. ”
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.