sorting appears to be logically correct