modified sort.py, stupidly saved as an HTML file