use key kwarg for sorted as it was deprecated in python 3.0: http://docs.python.org/3.0/whatsnew/3.0.html