ADDED SORTING FUNCTION AND TOSTR TO EXERCISE