cleaned sort function(s)