Modified sorting.py