take common sort helper functions out