Implmenting assert checking for sort() function