Fixed code for generalized sorting...but still not working fully.